Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1949385AbdDYPOv (ORCPT ); Tue, 25 Apr 2017 11:14:51 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1548 Lines: 43 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 --- 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; -- 2.12.2