Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933670AbdDSJKc (ORCPT ); Wed, 19 Apr 2017 05:10:32 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1217 Lines: 33 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 --- 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) -- 2.12.2