From patchwork Sun Jan 7 12:14:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 123667 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1549737qgn; Sun, 7 Jan 2018 04:19:35 -0800 (PST) X-Google-Smtp-Source: ACJfBot1lcfl7I15dweYTRAbZEbKMMonRwwSf3rbukDrWsUALz0XiR/RcD3ToSuxWOp5dePVhhtb X-Received: by 10.159.211.8 with SMTP id bc8mr9162597plb.142.1515327575882; Sun, 07 Jan 2018 04:19:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515327575; cv=none; d=google.com; s=arc-20160816; b=AA2DUfi1Nxjy0FPf/WB8hxAhy691q51rjcTZOWoGHWJ2Qe+wBjPqc0UkWuR+xD29pM IXRhZIdlo5nvjPb+N1W6sa/BoaqWgWUiM2qGOLXPLP+GgAjJpcfJuqezjwQHJq4LytXR 2rQe58WO0spoCKXybqlujaj+SnJ+y8qGUbreADVDg5Q5cXn0jcZRCNwbUU642FOo2Moj qwANMxfE6OU4fAtlX5NvBnGkSXAxlZgs7oik0F6E+rY1FjU48q/NILhASZ/Ff+/BrrdX i2ptZCaj/7i51p7G9RRxwlXjE+yMpQdyQnT4RLhCj9EBXxAnY6a2j0GXba+eUj6ujJCV RmbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=lB3FpQPkaGDl+fyzImlTAhjZY9kNIiVn+XYVHHCShGg=; b=VlTQKOjlG/xsevyYameTpjwnI30iPGnntKxksrSxkZ0GDa61ViPqmoHlDJoXymH9r0 SzeeX6WdRhxoH6EhXsZE4sd/zAykAKeFgqJXLQpA0Xv6TZjOXEJ4JXpsAN0J1z4ijrsM qgZyGNFYqzcHDc11o3a+nNsUGdEUgRjfS+4QeEm6N2UcFFkvSc5pyoCnBMtVbDpdfrH/ 7uZuLJnx/suvBnrPCudLs77oQaCoqZCkOJdIY4fcece1hbNQ1xtmjcO6JsDGbfYPYnlz rkSxh3D0TR8mrcwhv5cb3VTv3FM/qlqmzD29KKezea8ebInJH9BdVKW/++49bE3jylG0 diHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si6133141pgv.49.2018.01.07.04.19.35; Sun, 07 Jan 2018 04:19:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754132AbeAGMTc (ORCPT + 28 others); Sun, 7 Jan 2018 07:19:32 -0500 Received: from foss.arm.com ([217.140.101.70]:57626 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753738AbeAGMTa (ORCPT ); Sun, 7 Jan 2018 07:19:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E7591435; Sun, 7 Jan 2018 04:19:30 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EAE313F581; Sun, 7 Jan 2018 04:19:27 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org Subject: [PATCH v3 23/27] stating: ccree: fix allocation of void sized buf Date: Sun, 7 Jan 2018 12:14:34 +0000 Message-Id: <1515327285-8948-24-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515327285-8948-1-git-send-email-gilad@benyossef.com> References: <1515327285-8948-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were allocating buffers using sizeof(*struct->field) where field was type void. Fix it by having a local variable with the real type. Cc: stable@vger.kernel.org Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_ivgen.c | 9 ++++----- drivers/staging/ccree/ssi_sram_mgr.c | 9 ++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 6b92649..2ba15a5 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -175,13 +175,10 @@ int cc_ivgen_init(struct cc_drvdata *drvdata) int rc; /* Allocate "this" context */ - drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), - GFP_KERNEL); - if (!drvdata->ivgen_handle) + ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL); + if (!ivgen_ctx) return -ENOMEM; - ivgen_ctx = drvdata->ivgen_handle; - /* Allocate pool's header for initial enc. key/IV */ ivgen_ctx->pool_meta = dma_alloc_coherent(device, CC_IVPOOL_META_SIZE, &ivgen_ctx->pool_meta_dma, @@ -200,6 +197,8 @@ int cc_ivgen_init(struct cc_drvdata *drvdata) goto out; } + drvdata->ivgen_handle = ivgen_ctx; + return cc_init_iv_sram(drvdata); out: diff --git a/drivers/staging/ccree/ssi_sram_mgr.c b/drivers/staging/ccree/ssi_sram_mgr.c index 1a2a7f4d..c5497aa 100644 --- a/drivers/staging/ccree/ssi_sram_mgr.c +++ b/drivers/staging/ccree/ssi_sram_mgr.c @@ -32,13 +32,16 @@ void cc_sram_mgr_fini(struct cc_drvdata *drvdata) */ int cc_sram_mgr_init(struct cc_drvdata *drvdata) { + struct cc_sram_ctx *ctx; + /* Allocate "this" context */ - drvdata->sram_mgr_handle = kzalloc(sizeof(*drvdata->sram_mgr_handle), - GFP_KERNEL); + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); - if (!drvdata->sram_mgr_handle) + if (!ctx) return -ENOMEM; + drvdata->sram_mgr_handle = ctx; + return 0; }