From patchwork Thu Apr 27 09:30:33 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: 9702635 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 80A04602CC for ; Thu, 27 Apr 2017 09:31:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B09B268AE for ; Thu, 27 Apr 2017 09:31:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E735285F8; Thu, 27 Apr 2017 09:31:56 +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 1CF56268AE for ; Thu, 27 Apr 2017 09:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937906AbdD0Jbz (ORCPT ); Thu, 27 Apr 2017 05:31:55 -0400 Received: from mout.web.de ([212.227.15.4]:59437 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937894AbdD0Jby (ORCPT ); Thu, 27 Apr 2017 05:31:54 -0400 Received: from [192.168.1.2] ([77.182.201.44]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LetUF-1dtRxt1j4R-00qmQ6; Thu, 27 Apr 2017 11:30:34 +0200 Subject: [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_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: Date: Thu, 27 Apr 2017 11:30:33 +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:N6A+pW8PXheXiKiEfms2b+kZDZbZQbNhUHBubIIomZpIwMMF6BW kzGHfnMbRkL1lzFYPjSOd77Ipdygl8SR1SDWr6Auafu5yijL9Jon1g/2X+xavsjWvj6ZFWx PR69D61w17+HaKzt28A8S2ZElC9C1PTACMHUUOzFRj4d0ctoaNGcpQkNVyxli8V1/pD7RdS kojL3NmG32YQI/podr5Lg== X-UI-Out-Filterresults: notjunk:1; V01:K0:erCE6fyjtFg=:oVS0fg9HlLg0zW4ZWov6tg alaSjOp9tawnBe6tX/u6McA9lZpw3PRsxpDORZMbUQEBkWO/6NZrS6T258XOL8qiAp/bkkOOW 6sSTqJreXu5NgO7/w20Q74mZ8XHM3FpBimJ4PmN4Bf3HAyPQYs213vqPbda4wteB7IeBYm7tM dgyXVYMLkW+xfdfJlBLyngwHS5n/2ve99N6xtjAq/9ceMVbFPNKknPDFhP9w1lg1XzW5yu7jY L+gOT87yy+//ucGPrniZrBwII8HG0LNjLqAP3BU0g757pSD0eaWKBzNCwEXR8RccfHe0xKt3S 2K3vp3K+uEofOntsGx4shHwYROHlQd2sKFn/RxfmPcsYqXbC8QhovJaaqvP13dKXcIqI3CoZM SQ9P9JgA8rNLqAVzvom9s9lKX6lpSirZlEj2WTXwjWqfxRP0kbAfuUIl3oa2/5pWLZnSyUWo2 P7rHwG7RI99XjkMEfhnvTMuFyNwPHObdUNnzV0huLK1jRUpNYa9eGXzCap05fG/D8AoqS0vGk XqT7NI9aVTFbplmWd8u77yM4GwCKrw6w3e5sio/JVPqznjZmBAVZVVyAhGSbA6BPKJkXFMK+y qnmGYmseHIz7Qtb8d+6EeXn96OTXUGFQKcpSNu9lBucP7SN/str80OaOG274nv8M2UhObIkBZ EDG2DCL/FYbYfinqR2qTR2qaEYROhVKISn3zcq5w33cQOyJ81gLNuMH1v5YU/rDARS3C29bqU lyYjhuEkxDef0by+vuweSCriq27jFHTcRUY1gjWKu3rtd8AkZ2vVfCcEC7GM3Xj/Ov4w6AybF Y3ohQLg 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:35: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/nct6775.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 2458b406f6aa..d552ab7901a7 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -1073,13 +1073,12 @@ nct6775_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);