From patchwork Sun Jul 30 20:29:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= X-Patchwork-Id: 9870667 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5037C60353 for ; Sun, 30 Jul 2017 20:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 423B52852A for ; Sun, 30 Jul 2017 20:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B732856B; Sun, 30 Jul 2017 20:30:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C747028587 for ; Sun, 30 Jul 2017 20:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754537AbdG3U3g (ORCPT ); Sun, 30 Jul 2017 16:29:36 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:35147 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754516AbdG3U3f (ORCPT ); Sun, 30 Jul 2017 16:29:35 -0400 Received: by mail-lf0-f42.google.com with SMTP id t128so76956475lff.2 for ; Sun, 30 Jul 2017 13:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikanor-nu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EYHe0rICOswSFwpdRh7vbGvdefDX+92QQBFZYX5L1bo=; b=mmPasAkIJYtcf4oymMmE8Bf+hgKOp1+Um+dWsfjHs8M3542/oGYaohoBMXkmSZEHnj jIx2Ne4Y0dLPRKgm5kbs7l+bhjaNnBQCIFV3LmwdzlqIC77so5/ndG3xrpAHCnffMCMO eHmLGWmA66RfjI5pO+tHEk+NqQKx88Gd1CoV8xB1EF3XgXy31OJkpZcBH8ldTE3y+fZm 30Iz63dhdIAcJaq610oYKBgGodb/te8my9FOsTltAIjWuQ7cVX/36Jtwa83tHWN+3eNU rCoFkSOB93zVmKQAwupgsaBhihm+2psYy7n/fjDywcHxrbJwHbneke4UhfpbpB0IH2uF vGrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EYHe0rICOswSFwpdRh7vbGvdefDX+92QQBFZYX5L1bo=; b=g6gtYur+fUrqF0vHudaBeViYz0wUtPP3ejmMqnel/MqZDNqWoCWogQdUYMZwZRNQZt iVldsgxmiROXmIfstJ0YIfemB0vz7yzqT3FZnmH7+hKpTgUKmpBsJafzo3g75NmhreUE TYlfn6kCHPP2ZIzDjMO7+X6jiLlR6qeRPxjhWIDvgfr20e7CstzaC8ACjn/NYqyDI+v9 OSGUYOqgfLtzg6pRwSqmtlQPpRQeRDJZbHt/cFPd3jL2NyOlZRusW32yVohZneBkn3Ce upjAKJxrfUvUKOZ2remw2m+vGOkDUcZMp9e8gPCzXwe3C3c++GcKeVGU/8ic6QBaHZGl tUDw== X-Gm-Message-State: AIVw112lt07IVSwyUk+TN8QJa0fIqMoGDNF+FOT4A/pk+kIKYMiupiWl SMjhQZzDMx6ixEWS X-Received: by 10.25.193.208 with SMTP id r199mr4679392lff.60.1501446573487; Sun, 30 Jul 2017 13:29:33 -0700 (PDT) Received: from epsilon.nikanor.nu (h-129-173.A258.priv.bahnhof.se. [81.170.129.173]) by smtp.gmail.com with ESMTPSA id 16sm5466603ljj.12.2017.07.30.13.29.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jul 2017 13:29:32 -0700 (PDT) From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= To: gilad@benyossef.com Cc: gregkh@linuxfoundation.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Subject: [PATCH] staging: ccree: Use sizeof(variable) in memory allocs Date: Sun, 30 Jul 2017 22:29:02 +0200 Message-Id: <20170730202902.8953-1-simon@nikanor.nu> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fixes 9 checkpatch.pl warnings of type "Prefer kmalloc(sizeof(variable)...) over kmalloc(sizeof(type)...)" in staging/ccree. Signed-off-by: Simon Sandström --- drivers/staging/ccree/ssi_aead.c | 4 ++-- drivers/staging/ccree/ssi_cipher.c | 5 ++--- drivers/staging/ccree/ssi_driver.c | 3 ++- drivers/staging/ccree/ssi_hash.c | 8 ++++---- drivers/staging/ccree/ssi_ivgen.c | 5 +++-- drivers/staging/ccree/ssi_request_mgr.c | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index f5ca0e35c5d3..5abe6b24ff8c 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -2659,7 +2659,7 @@ static struct ssi_crypto_alg *ssi_aead_create_alg(struct ssi_alg_template *templ struct ssi_crypto_alg *t_alg; struct aead_alg *alg; - t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL); + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); if (!t_alg) { SSI_LOG_ERR("failed to allocate t_alg\n"); return ERR_PTR(-ENOMEM); @@ -2714,7 +2714,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) int rc = -ENOMEM; int alg; - aead_handle = kmalloc(sizeof(struct ssi_aead_handle), GFP_KERNEL); + aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL); if (!aead_handle) { rc = -ENOMEM; goto fail0; diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 6219a92184aa..af9afead7bcb 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -1218,7 +1218,7 @@ struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template *templa struct ssi_crypto_alg *t_alg; struct crypto_alg *alg; - t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL); + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); if (!t_alg) { SSI_LOG_ERR("failed to allocate t_alg\n"); return ERR_PTR(-ENOMEM); @@ -1279,8 +1279,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) int rc = -ENOMEM; int alg; - ablkcipher_handle = kmalloc(sizeof(struct ssi_blkcipher_handle), - GFP_KERNEL); + ablkcipher_handle = kmalloc(sizeof(*ablkcipher_handle), GFP_KERNEL); if (!ablkcipher_handle) return -ENOMEM; diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index a4ab9ef4baf7..88b68c81556c 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,7 +223,8 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), GFP_KERNEL); + struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), + GFP_KERNEL); struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 1a405bbadf6d..13291aeaf350 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -2060,9 +2060,9 @@ ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed) struct crypto_alg *alg; struct ahash_alg *halg; - t_crypto_alg = kzalloc(sizeof(struct ssi_hash_alg), GFP_KERNEL); + t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL); if (!t_crypto_alg) { - SSI_LOG_ERR("failed to allocate t_alg\n"); + SSI_LOG_ERR("failed to allocate t_crypto_alg\n"); return ERR_PTR(-ENOMEM); } @@ -2226,10 +2226,10 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) int rc = 0; int alg; - hash_handle = kzalloc(sizeof(struct ssi_hash_handle), GFP_KERNEL); + hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL); if (!hash_handle) { SSI_LOG_ERR("kzalloc failed to allocate %zu B\n", - sizeof(struct ssi_hash_handle)); + sizeof(*hash_handle)); rc = -ENOMEM; goto fail; } diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 86364f81acab..b01e03231947 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -191,10 +191,11 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) int rc; /* Allocate "this" context */ - drvdata->ivgen_handle = kzalloc(sizeof(struct ssi_ivgen_ctx), GFP_KERNEL); + drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), + GFP_KERNEL); if (!drvdata->ivgen_handle) { SSI_LOG_ERR("Not enough memory to allocate IVGEN context " - "(%zu B)\n", sizeof(struct ssi_ivgen_ctx)); + "(%zu B)\n", sizeof(*drvdata->ivgen_handle)); rc = -ENOMEM; goto out; } diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 2eda82f317d2..e5c2f92857f6 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -100,7 +100,7 @@ int request_mgr_init(struct ssi_drvdata *drvdata) struct ssi_request_mgr_handle *req_mgr_h; int rc = 0; - req_mgr_h = kzalloc(sizeof(struct ssi_request_mgr_handle), GFP_KERNEL); + req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL); if (!req_mgr_h) { rc = -ENOMEM; goto req_mgr_init_err;