From patchwork Wed Apr 19 09:10:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9687085 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 329CC60375 for ; Wed, 19 Apr 2017 09:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237F328342 for ; Wed, 19 Apr 2017 09:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1800D283F4; Wed, 19 Apr 2017 09:10:33 +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 B219028342 for ; Wed, 19 Apr 2017 09:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761287AbdDSJKb (ORCPT ); Wed, 19 Apr 2017 05:10:31 -0400 Received: from mout.web.de ([212.227.15.14]:52813 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933045AbdDSJK2 (ORCPT ); Wed, 19 Apr 2017 05:10:28 -0400 Received: from [192.168.1.2] ([77.182.113.86]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LdVha-1cIKFl2XwY-00ions; Wed, 19 Apr 2017 11:10:11 +0200 Subject: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe() From: SF Markus Elfring To: linux-crypto@vger.kernel.org, "David S. Miller" , Herbert Xu , Matt Mackall , Shannon Nelson Cc: LKML , kernel-janitors@vger.kernel.org References: <4d9fbb01-e12f-eb5c-7ecd-5a2a10fd5110@users.sourceforge.net> Message-ID: <38c41219-7e7f-3a3e-29dd-04ae2d57beaa@users.sourceforge.net> Date: Wed, 19 Apr 2017 11:10:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: <4d9fbb01-e12f-eb5c-7ecd-5a2a10fd5110@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:58eOoQ0r8h9dugk9D88OJPQ2f/iEYvqC0J4OxvXHjeFlIkvoLZl 6MZOmAS980H1oQT9OQyGxHyJo1iZ9BjBvnF2u0/NO8i5JtysAhQ2j51qfsaAi9CeswE/aWT vxaNiWw1y3qiD5wnHPxrvLnJaevbIF82vu6hjPbRMwNNMeP6Sfqq2dKnLd5Uu/NT/tHPTxa Hl/0EldnDZvvGTp2eQyjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:AIyBo8b/3l4=:vq+A0ahOiftg8s5ZI1eDA2 jYQpmVMecSXL2PYVJRN5OmHE1i9hDw6i7gvDy/9gqAY3/+LlX78dp7tUQlKxljRvl1Ab7p4qf HkjqtQmsbQ66hYhyy48h/xfw9oE8aQ4QULNpqvwzRUBQz0bPEOIjNalu3sSJ0K9PRlJqwrh87 vOfyvQAmQ1GSDJitkFCKLUlHsMxvmCJggooEncGnubLGTQH75CHy6Y3jT+YkOZcB/9Kn2uAQZ hNDPP4G6I1c2/RHFRkHNzH6ZR3T5cwOkwyIVL8xhg7rbaZ9Pduw4NiUItI7A3uN2Nyw8GYFnx HXHdbqZe2ZPRH/OwctUuu6SxKc9dGywe+ahgWlf34/dpJiAal08YlM5v8D6CKalrYFhcNshGt i8iTNrdRDDWiywzYX0i51KVutVc063FmF8mA1mY9ksR/YFO3mZHBMijeooHYqho8LSEG3EzXj N+R6odNIlb48ArqhufcP0R6NZtBWAoaOkbPO5fEMmshUmvFhjCOv4PQ245B4PbQNgEAJCRVGJ Xs/RRLgz9myjspSzuFCD/k3MMEzd1sUOqbi7lgaYP0jDGqviu3wUBHOoM5aUp6xaigkvPZDTj BeQC/NdgGP7bwGMLDJIVF+OTmOU/h4zk70AMVxM+jf3kUPwNhXrDNqLouBxWLdXQU9CtEyTnJ 5T/WqY0rFUHnvDWi+vLRwdC/DCFqwgww0sImwptmH3cGxxu8Kix6FEGqEm6hcD3gIz+m0+zwS zQ6aJDz7h/wKrHEaWZajxLBno1v+ktJjxeFQ+ZeQ+qgpc/6sz1h/EmQQO1YCe5ExPD1GC1ZZg 7fDdSaP 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: Wed, 19 Apr 2017 10:30:47 +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 "devm_kcalloc". * Replace the specification of a data structure 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 Acked-by: Shannon Nelson --- drivers/char/hw_random/n2-drv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 31cbdbbaebfc..92dd4e925315 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c @@ -748,9 +748,7 @@ static int n2rng_probe(struct platform_device *op) dev_info(&op->dev, "Registered RNG HVAPI major %lu minor %lu\n", np->hvapi_major, np->hvapi_minor); - - np->units = devm_kzalloc(&op->dev, - sizeof(struct n2rng_unit) * np->num_units, + np->units = devm_kcalloc(&op->dev, np->num_units, sizeof(*np->units), GFP_KERNEL); err = -ENOMEM; if (!np->units)