From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756881AbcIPBuW (ORCPT ); Thu, 15 Sep 2016 21:50:22 -0400 Received: from mail-db5eur01on0056.outbound.protection.outlook.com ([104.47.2.56]:57195 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755103AbcIPBuJ (ORCPT ); Thu, 15 Sep 2016 21:50:09 -0400 From: Horia Geanta Neag To: SF Markus Elfring , "linux-crypto@vger.kernel.org" , "David S. Miller" , Herbert Xu , Labbe Corentin , Russell King CC: LKML , "kernel-janitors@vger.kernel.org" , Julia Lawall Subject: Re: [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() Thread-Topic: [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() Thread-Index: AQHSD1+AP3VrroVyPEW4O2nIwqYC6A== Date: Thu, 15 Sep 2016 15:12:53 +0000 Message-ID: References: <566ABCD9.1060404@users.sourceforge.net> <970e9e1b-c1dc-eb28-b380-92c15e9b1961@users.sourceforge.net> <4e1bc780-fa00-cfc9-c058-240bb899d701@users.sourceforge.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=horia.geanta@nxp.com; x-originating-ip: [192.88.146.1] x-ms-office365-filtering-correlation-id: 5036260c-0630-4529-9942-08d3dd7ac45e x-microsoft-exchange-diagnostics: 1;DB4PR04MB0846;6:ht2q3VQiVljQZq0j159CA7a2+Qns722qCMyExwX889snHyoTFUJToJxU529zQ6FTpESW3zBT7UznoDy2BlDyXvNGWpM/36xRwrx7Ql0Lhk//FuRvgWYIZqbtz0noxImhjZAGTyeNVgi0F2VblXxuYG4V++B2Ttzz7x0d8K5PXJiVOJzarovg3pvjQMd7ja2zMWp/kkt3FmqseVU+vFiTVBnUMP8M8nJhQcX2xV9lC/q3/2ixidg1uZ6/h0xP3ek2VAFObgxOiq1sW8EbV5Iy+0jFR+K/FKX74PZhAoaffVkRoKF2cqI+m4BuTcQVTcowLfW13Osvkq9/KVcWTC+szg==;5:sxSWaiUIeR+VebRVFS7NU1vs+jI2TJRaNzQo+XRz8Vqkic2cDhcX6xIk9x6IV1YVgLd552u71rNrMfkFZW+VVz2vpRWMUhcl4UNcuyDfcE+Zt6xBmOEzJQq4BWW3sg3ZKTfvvqslaygQrb/fLZFvVA==;24:2a3laYLxlhP19TqYcd79WSW09QJan5KQVO1YA3WyaBDkVEO6X9L6blriEvAU6O09gO8dLj2Pd0kMujoo9XhFdXePSdyUg8hYF07qo0hlBCs=;7:I6vCZ+0TLbG/uz9UjtsZ5RBI0PcpoUkuykt71nXjuZMSU5jgncDRjATY7cBhWsZicXGzx+rjrCNPeQ0plY3+UVNtCi2kPLh/TFBCu7Q/37W8V3Eu730ixv+SqwDEovm17XasIEsSBp3JKP4Omm3K46uUlJNYGi0HIAnvXkYV/IAb0AoGSqIU/RuGKvQSaeNH+HOXTWJvCCFr70r7xbhEqHbX4xNaWZ9pXE27iSKjpD1FQCFQYaBRREm7p7jVNAGI x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0846; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089)(42262312472803); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:DB4PR04MB0846;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0846; x-forefront-prvs: 0066D63CE6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(377454003)(24454002)(199003)(189002)(76576001)(2906002)(81156014)(81166006)(74316002)(7736002)(7846002)(305945005)(189998001)(101416001)(87936001)(5660300001)(50986999)(5002640100001)(8676002)(54356999)(76176999)(106356001)(11100500001)(7696004)(77096005)(33656002)(2900100001)(19580405001)(19580395003)(97736004)(86362001)(9686002)(5001770100001)(68736007)(3280700002)(3660700001)(10400500002)(66066001)(8936002)(6116002)(3846002)(102836003)(586003)(2501003)(92566002)(122556002)(106116001)(4326007)(105586002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB4PR04MB0846;H:DB4PR04MB0847.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2016 15:12:53.7422 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR04MB0846 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u8G1oQXE009475 On 9/15/2016 5:43 PM, SF Markus Elfring wrote: > 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); While correct, instead I would go with kmalloc() and get rid of sizeof(u8). Horia