From patchwork Thu Sep 15 14:40:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9333809 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 C5C226077A for ; Thu, 15 Sep 2016 14:40:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7180298C1 for ; Thu, 15 Sep 2016 14:40:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9BA298CA; Thu, 15 Sep 2016 14:40:54 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 35FB0298C1 for ; Thu, 15 Sep 2016 14:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752418AbcIOOkf (ORCPT ); Thu, 15 Sep 2016 10:40:35 -0400 Received: from mout.web.de ([212.227.17.11]:57089 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbcIOOkW (ORCPT ); Thu, 15 Sep 2016 10:40:22 -0400 Received: from [192.168.1.2] ([77.181.210.244]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LqlSQ-1b6EwM2kC2-00eNB4; Thu, 15 Sep 2016 16:40:08 +0200 Subject: [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() To: linux-crypto@vger.kernel.org, "David S. Miller" , Herbert Xu , Labbe Corentin , Russell King References: <566ABCD9.1060404@users.sourceforge.net> <970e9e1b-c1dc-eb28-b380-92c15e9b1961@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <4e1bc780-fa00-cfc9-c058-240bb899d701@users.sourceforge.net> Date: Thu, 15 Sep 2016 16:40:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <970e9e1b-c1dc-eb28-b380-92c15e9b1961@users.sourceforge.net> X-Provags-ID: V03:K0:ubY4yQn4gYoZmTg8256PQBDlIxWkjOGdaBLy5sErmfq8YX7Xvai BIntSTyaqFSMex+wLIfluKyDLaecB43NwbRF6A6LJNAxSLrveQmRnh6KPG+PAn1ZnU/USh5 BvmnMyT5seGUiOGR7zP8O4faatr/KGXnpIqfK6PdIKPHlV/xW6I5RK4PaL7qDIBTf7ixEDM ciAPWwYQwXmLYpyp/U60w== X-UI-Out-Filterresults: notjunk:1; V01:K0:Oi4yJSMJylU=:7CEVYTQzv+FJY6ZBLceJYN +aNWv0auPxew3m91o3nk8F+h7X4Ntwvk/K1N4l10jCrt8WDza8y4UZchRiftxWZtn5lHdToOC IkoK1Bzb4uu3AjrUQlhIslx0DDUFm1ErBZAuS8iR5XjfRuPla8UgPqkRQoBhs6G5SA82fO3w6 6a8iPw6e0HWOu8lbVVKQp54xs3c5897s1UJ7C8Ay3I9VZFeFA95fiPY6Nq1HjQH9ESRFfQuj4 dX2RnuENFKMIVKnnu1Mq5syD0kQOZ2eRaUHZZRKOrVSq+aYgYZyLd2YUj/gQ+UHqUvflgrswo HV0Je/nAaQrUQs+B0M4Kr0Pxtwwnnsw8TDExCFXjGbd4iKycAxqa2mNvr8gaVgUVrcp3YTsi8 kyrHVxw3GBEUy2POPx+77AxO3ykDcFAjkUEQ54IBrgithhKRZ6n36JXgU7lfcoXUmbh1PdK4L EV33F+LWP98/WPJLRAsyzP7J4BtW1RYX5vn+DDdNHpr5VEkToWrjkCNGkOOWIKWruFUh+TXd6 FQrlm3511h4Ejndogf9GNS97HFtudFGz318NfudNF2jAgG2BEOgqJ7QXoQX6isTyx0LEqh78k tmjYcC7At50+LezdjqSAgB+Pj//eCsuGe1FiXR578uVEE1kqQf9LxXoZw+H8idiCpXX6LHqSB mKrEDj/pftF10+0o1m3MFEEJ6zjIW7wMfL+L3LGrbFQOw64p5LvUZz0Exuuu3U1HdrKG5RztU Mxrgj8m6MkgGipOvjuHbSKgyoWsPKUspwh+VjH+1sf3SQiLWPyUjEvEdxRHY6KXn3bMciliDC vZ4bTXr 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 From: Markus Elfring Date: Thu, 15 Sep 2016 11:20:09 +0200 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/crypto/caam/caamhash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 9d7fc9e..f19df8f 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -525,8 +525,9 @@ static int ahash_setkey(struct crypto_ahash *ahash, #endif if (keylen > blocksize) { - hashed_key = kmalloc(sizeof(u8) * digestsize, GFP_KERNEL | - GFP_DMA); + hashed_key = kmalloc_array(digestsize, + sizeof(*hashed_key), + GFP_KERNEL | GFP_DMA); if (!hashed_key) return -ENOMEM; ret = hash_digest_key(ctx, key, &keylen, hashed_key,