From patchwork Thu Apr 27 09:28:45 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: 9702627 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 E6006602CC for ; Thu, 27 Apr 2017 09:29:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBAB628630 for ; Thu, 27 Apr 2017 09:29:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0B5B28634; Thu, 27 Apr 2017 09:29:52 +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 7916928616 for ; Thu, 27 Apr 2017 09:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032541AbdD0J3i (ORCPT ); Thu, 27 Apr 2017 05:29:38 -0400 Received: from mout.web.de ([212.227.15.4]:53758 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936396AbdD0J3h (ORCPT ); Thu, 27 Apr 2017 05:29:37 -0400 Received: from [192.168.1.2] ([77.182.201.44]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LmuMO-1dkPT92ChI-00h7qH; Thu, 27 Apr 2017 11:28:47 +0200 Subject: [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group() From: SF Markus Elfring To: linux-hwmon@vger.kernel.org, =?UTF-8?B?R8O8bnRlciBSw7Zjaw==?= , Jean Delvare Cc: LKML , kernel-janitors@vger.kernel.org References: <2f58a509-4aba-5c44-bc79-568b260ab692@users.sourceforge.net> Message-ID: <719f2298-cd74-8769-b52b-1be9568b3851@users.sourceforge.net> Date: Thu, 27 Apr 2017 11:28:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <2f58a509-4aba-5c44-bc79-568b260ab692@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:KDqRce3nxbU5YDbVz83q9FngOKMcktLesWukqvtrVczqC1vGV7J 4szIVMx3u6uFYqKN7Ubo/SDhEVcTyMzovV/qkxrnotXjDUGmpOyrjaTU7PXy4Tl9xp5oegp hZ//Ij/GNKdHOA6NFgdmeunWbyeEQSGVpeAKWX+SCwO7H02ZwZ16FWXMwdE+fHv5p5ohrx2 3tbIPxN7aQL5VZ+1AOpmw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fyg2fKq4QgQ=:g/gzHh4z8JaW0WBSaunepX EV7qUgetSLBAx86qe/vQ389R07q5NY5WhkT20yjqInhCLM84G//MOwFB+KU2yuNtapukc+hPM AKzkxs7kSCvjBwiKDqgWRhhrxeYxIEnjNvKGwioGOVZP1NjX4babGlExkb+IT827mqLWz/NFb KlsgGZkXHNktjbStwrGse33/AreAceGCJCV4tuUEdgy980NUS+lwXq96YiK+6stdNIXShV1ue P0wAe8aSomrxHY5SLTWb1HZQbZzrmsZsIDFSuIHx0h7lPaXdC58XD0gCOPFgscdqhQYL+c4tI q04Nyc7b6L5cICw7i31SQaxYvQ5Vy3OIpD+63HiBMEeRDkE6xXirNej9YfLw/PVMZ6Gq1e+Se Dzezc3OoI5/btcDb8AoxoghX7S726UOW2lqobIg2NPrawazXjEnPSH8dhD+fCUBBpkV590isd 5+KUc1J6TvB+vP5mAtTBLYGDqZr+ge2rUxInPEXznLiJVICmYmMHh2HU5gA0a3+o0vSzq35rN w01Ihubr9yGx9lqOpHRDavWMNBu1EHRaksGXmOF1woxEu20ZMj5+k0NdHPCpUlubUq6stBDzx yWszn9cOlkIx4AKOM6hNgpzSAFj+Opt0bloYjk434gp+MQuCEMJSM7VHTy5IgzmJ6ybRAC7rd nVpSwg0VsFVQrCuIzRd03ZhcHRI3pkbXGHM5lXxIf1HY7q7sbkBE4Fw7+Qnm5AgwpLSRv56Cj rdxFs69aQRMIwqB3aip504RnQF7CNMyaM+w6Dk4LVeLwfRlWosGVQvce+IpYuzXP7K1vSvtHV Asid8nD Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 27 Apr 2017 10:10:36 +0200 Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/hwmon/nct6683.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c index 8b0bc4fc06e8..dd14a98cc6dd 100644 --- a/drivers/hwmon/nct6683.c +++ b/drivers/hwmon/nct6683.c @@ -426,13 +426,12 @@ nct6683_create_attr_group(struct device *dev, if (group == NULL) return ERR_PTR(-ENOMEM); - attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1), + attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs), GFP_KERNEL); if (attrs == NULL) return ERR_PTR(-ENOMEM); - su = devm_kzalloc(dev, sizeof(*su) * repeat * count, - GFP_KERNEL); + su = devm_kcalloc(dev, repeat * count, sizeof(*su), GFP_KERNEL); if (su == NULL) return ERR_PTR(-ENOMEM);