From patchwork Tue Apr 25 15:13:55 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: 9698451 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 4D9F06020A for ; Tue, 25 Apr 2017 15:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4503D28645 for ; Tue, 25 Apr 2017 15:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3999D2865B; Tue, 25 Apr 2017 15:14:29 +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 2395528645 for ; Tue, 25 Apr 2017 15:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1949346AbdDYPOZ (ORCPT ); Tue, 25 Apr 2017 11:14:25 -0400 Received: from mout.web.de ([212.227.15.14]:54114 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1949061AbdDYPOP (ORCPT ); Tue, 25 Apr 2017 11:14:15 -0400 Received: from [192.168.1.2] ([92.228.145.161]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Mcnuz-1cl5fh3jm5-00Ht2K; Tue, 25 Apr 2017 17:13:57 +0200 Subject: [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions From: SF Markus Elfring To: linux-input@vger.kernel.org, Benjamin Tissoires , Jiri Kosina Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Tue, 25 Apr 2017 17:13:55 +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: Content-Language: en-GB X-Provags-ID: V03:K0:HNoIyxNPjBxEtmtLGHddlGhg/ntbYaH5F9H5KywBKDEvKAP7zEk 8y7MN2BEvCIS2vE7AJRrqUdL8kzx1SKAtTSJJ4FZgcw2IqiAAV87wgjLVXe88LHE/oeKZC5 6I5FalT1Hmr4nCTb9KnqIbJ6jl+mWAq9IOJql0AWjZegygH24gau/KNlud5QwzfJwlgdhpe lz/FGuMSDHTgbvL+PlGvg== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZlP7LVettC0=:duP7GjuiXntGGcSJ1WbGH/ byEBrCjfF3Qo/7P9yhKqMnaVkEXFylygmmFgMM4uxAZbF2sWz3L3WBDNpKzyR8Is+rsUJ0DvO qLseoLpf7+GZh306wd/ON60k3uCQx3UzqGTojQxIdoam8zMFKyGh7n6Xyl6dpKqKKodQtThRe YFRIzMz8r54d6mJLrtWy+h6F82E7HDmkt2Yuk/lR85rCISwJvy5RYUA37YESgB4C35G8d1xBx zUKb/3LptPTr0qPp/JahIvBNRgaoh/kMM8NoZG7sL5jJ2JirO2dJBX1R8Qf6PcsVm2cpiwYRS C6u0EunaEHYgX4byeO78Hj4uVRgGLyQc0Z+GLjYiAbgFAM69QJo/uNElxVo0tse+VcqedFqYx iy59ndTqGDmtcE4kJCvZ1WVvp893QUXhcZi8RlTSaMFLHsulsebLU15GB6XFznPQ1SQN7BjjO zne1w89G6LGalU87qxtyHDWArfTPYpn8erWIEciTycsx9IqM/0EdPwM3ngdI1AzV2PgUeg/Cu JJ43JpiBVqVICpyDuIez/OUrZQW257EpOVW43IF2fHkpTiJInKmhm1yVsbjyYk4fENQEPxKa3 xH3l1vtp+LDBNCOdXo2WyLIqM4LAV4WfrJFWMkqZ7BKvcEPMdLcGoF0L2XiBk2R5HEyEFaKAI C4EhhueN6K9tO+t6CIKD3QZRcNmSVh4iraqYDRQEzSZU7lCGa4fDzwmURGbBc2anIdfmqhfiy /oz+33WG9N1lTuMm2NW8rr0OhQmqb8sHIUgyJt8kOHAV53z7Jt23GN2Z/0Vr8e8rmb0o2YohN KxRl9O/ Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Tue, 25 Apr 2017 16:06:08 +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. * Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Reviewed-by: Jason Gerecke --- drivers/hid/wacom_sys.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 0022c0dac88a..550faf8819ea 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1245,7 +1245,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev, if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) return -ENOMEM; - leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL); + leds = devm_kcalloc(dev, count, sizeof(*leds), GFP_KERNEL); if (!leds) { error = -ENOMEM; goto err; @@ -1345,8 +1345,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count) struct wacom_group_leds *groups; int error; - groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count, - GFP_KERNEL); + groups = devm_kcalloc(dev, count, sizeof(*groups), GFP_KERNEL); if (!groups) return -ENOMEM;