From patchwork Mon Jan 1 12:06:50 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: 123056 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7798447qgn; Mon, 1 Jan 2018 04:11:27 -0800 (PST) X-Google-Smtp-Source: ACJfBovnAhPVenrzBzKylGLTwfu2R67dLO43+ZGd0UvvCwYaqtZO2AEuqa64oMMA5Ux7p3TTvZNi X-Received: by 10.98.194.150 with SMTP id w22mr43011426pfk.67.1514808687633; Mon, 01 Jan 2018 04:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514808687; cv=none; d=google.com; s=arc-20160816; b=UQLeVAt1b0Jg/T3T1r5oMDDzGFry+q23AyO1y8jKcb00U0JDBjBjPtXVfO4J7nuYL9 FrZZZJ1NJagpp3vzOttr+nSXj8QALjY4BtJZrjH9Y5Qc5Pv4391ztDCocKv6A9gh/mI2 mQXmIELfjKh4PrQV4Q7NT2MZRsU3RHXIzCKvNP3/52hM2OAyALhKDsbcSjUYOiOXQUlu 4UOVYm6VQ5wWe2Hq0X+NInlSGJ/380yIOlJbig5AJyI1XQUkg4QQtwCpaZwQh7X/qz77 4uJXOmsmqla/3SOo7NTX32bGzrTm0wLCtJW+x4+kneRP/DvCtzpcdFeB3fQojYcobCsk Fu/g== 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=UlER+t0z9EtN2gSegzVPrHvK4NI+mL2GxbjB/8kXvjE=; b=C+uAnplokdVPw7/mP5FmkuXZqddE+nOg8jYbfl1zE7BGXHHoTxvkXWIR8cWDxSf/aa dIKYsOgl/X3KcwdksEIusAOTymChQuKG48jqomy4rjYhKp8vbvcGnovqtEw41W2UULgY I2DzmD6sFvthhlASobLEspOY2DjHVtjPRZSgL9PzkkkxxtaAhrkEnk4SPaVFKYMkWN6u 4mxO9125S1kYsBqyr8oLNboXVVxXCuBh3nJKr7/IzHkUCKr17XgmBlDd+I8p6O3W+GDT YH87Iae3LRofhPOq1yRigtTDTTiA9XAgsGjBa0C1av0Emlfrbe8MBbWeDIzy0Swa/2GM tl5A== 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 y7si31937112plk.17.2018.01.01.04.11.27; Mon, 01 Jan 2018 04:11:27 -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 S1751815AbeAAMLX (ORCPT + 28 others); Mon, 1 Jan 2018 07:11:23 -0500 Received: from foss.arm.com ([217.140.101.70]:59264 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeAAMLW (ORCPT ); Mon, 1 Jan 2018 07:11:22 -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 BC4BA80D; Mon, 1 Jan 2018 04:11:21 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C36193F24A; Mon, 1 Jan 2018 04:11:18 -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 23/26] stating: ccree: fix allocation of void sized buf Date: Mon, 1 Jan 2018 12:06:50 +0000 Message-Id: <1514808421-21993-24-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514808421-21993-1-git-send-email-gilad@benyossef.com> References: <1514808421-21993-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/cc_debugfs.c | 3 ++- drivers/staging/ccree/ssi_ivgen.c | 9 ++++----- drivers/staging/ccree/ssi_sram_mgr.c | 9 ++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/cc_debugfs.c b/drivers/staging/ccree/cc_debugfs.c index 62bf011..140c04b 100644 --- a/drivers/staging/ccree/cc_debugfs.c +++ b/drivers/staging/ccree/cc_debugfs.c @@ -6,6 +6,7 @@ #include #include "ssi_driver.h" #include "cc_crypto_ctx.h" +#include "cc_debugfs.h" struct cc_debugfs_ctx { struct dentry *dir; @@ -24,7 +25,7 @@ struct cc_debugfs_ctx { */ static struct dentry *cc_debugfs_dir; -struct debugfs_reg32 debug_regs[] = { +static struct debugfs_reg32 debug_regs[] = { CC_DEBUG_REG(HOST_SIGNATURE), CC_DEBUG_REG(HOST_IRR), CC_DEBUG_REG(HOST_POWER_DOWN_EN), diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 8051fa1..44acded 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 0613aaf..5bf37bf 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; }