From patchwork Wed Jan 3 13:35:30 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: 123320 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp10184201qgn; Wed, 3 Jan 2018 05:40:28 -0800 (PST) X-Google-Smtp-Source: ACJfBotVBAyH12OVBX+Js/NCj2uqDF2H4te34ydOzoxd6sPtevKhn+rL2893H8CaZmcMQaU0y8CP X-Received: by 10.101.97.145 with SMTP id c17mr1316748pgv.105.1514986828833; Wed, 03 Jan 2018 05:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514986828; cv=none; d=google.com; s=arc-20160816; b=QAu2SIVcv0/WYth9FvzZ8A9wRM6P2AEPE2EoR0IYLWvFqpSNt6YnruEqr+amFqFBM2 ufnc2353Lehlb1oND2EWBpXPTYM2+AYp7D1PwkpDgMsrE074n3piWq6eIG6AYcEdHANz GvVMFRFY5qsZTT/GB9N093MTEW6Bw/4nYC/5SptzMiId6ZYh6dACj8eG9vmHK8DDgAW8 bC48wcFA5JJ8ZPmxO/o0abIEkJmi99QYhzpZCZY2SHatC/AeUfDliomAYCUqJoFQHkho /6B7KjpDponl4OM6Hk1LJcA3SXmvxd9SxrsKbU1H5xJXyIMQQhir3ve5QIMKUxBcPIcs y6QA== 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=Y4Cb8bQMeL8JjVJ3KljxAr5QZ6KTtKyv3yZTI2gPXOE=; b=VmIrConovCJd/P+r02krdE9FTO6IsaqjmRo9cyoWveVjrJ+C6s2chs3L993KyVWHk9 RMBYpwAIxNr+N1XcqL0OL+4iaQcG2T0Jm5YIYjU0lMgHIMWXMB90+DkEcGgjXqPdr6Ek Kqz82kjKbMTLaiA8DlBziDdYLugITpd0rnQFoWeuf1pQi95XlczC8o3ZyLjbzheavk5y vpVOsl5JTtDs5tEreDuRZMxMu+TW3UAM/fSa/gCu2WpmA6Yxewhi/iLPhkYiCyjnbNU3 YHEsX6ziGN1cWCIGN2SdEQHJ8t9qMHdFnqLMkdZsuKYrC3dt2ub4cd7Pigsw0FhNmrZW 4MhA== 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 d2si707306plh.536.2018.01.03.05.40.28; Wed, 03 Jan 2018 05:40:28 -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 S1752687AbeACNk1 (ORCPT + 28 others); Wed, 3 Jan 2018 08:40:27 -0500 Received: from foss.arm.com ([217.140.101.70]:50250 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751463AbeACNkY (ORCPT ); Wed, 3 Jan 2018 08:40:24 -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 14EBC1529; Wed, 3 Jan 2018 05:40:24 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5789E3F24A; Wed, 3 Jan 2018 05:40:22 -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 v2 23/27] stating: ccree: fix allocation of void sized buf Date: Wed, 3 Jan 2018 13:35:30 +0000 Message-Id: <1514986544-5888-24-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514986544-5888-1-git-send-email-gilad@benyossef.com> References: <1514986544-5888-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 94a0502..9d8d307 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 e178385..3a93299 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; }