From patchwork Mon Apr 24 20:16:09 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: 9697133 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 8CAC5601E9 for ; Mon, 24 Apr 2017 20:16:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8168028066 for ; Mon, 24 Apr 2017 20:16:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75DBD28419; Mon, 24 Apr 2017 20:16:26 +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 208C828066 for ; Mon, 24 Apr 2017 20:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1174262AbdDXUQY (ORCPT ); Mon, 24 Apr 2017 16:16:24 -0400 Received: from mout.web.de ([217.72.192.78]:61890 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1174242AbdDXUQX (ORCPT ); Mon, 24 Apr 2017 16:16:23 -0400 Received: from [192.168.1.2] ([77.181.233.174]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MGRdk-1cpZ8O0wwy-00DH0j; Mon, 24 Apr 2017 22:16:12 +0200 Subject: [PATCH 1/7] HID: sensor-hub: Use devm_kcalloc() in sensor_hub_probe() From: SF Markus Elfring To: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Benjamin Tissoires , =?UTF-8?Q?Bruno_Pr=c3=a9mont?= , Henrik Rydberg , Jiri Kosina , Jonathan Cameron , Srinivas Pandruvada Cc: LKML , kernel-janitors@vger.kernel.org References: <2d526d72-a740-367b-04a9-ed698435f8ed@users.sourceforge.net> Message-ID: <8a50aeac-0c9e-fff9-a7e7-61bcd733dfce@users.sourceforge.net> Date: Mon, 24 Apr 2017 22:16:09 +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: <2d526d72-a740-367b-04a9-ed698435f8ed@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:Xvp3I6nqq0lPbXbbV5UWU7rNy9iL3umuy22y32A2i3zgMx6bI9Y u4eo/x75e/NbPbmou9Jqrt9GbhhftVnecNvnA++S4A9OcB5ssM/qx+aevSVl4TBKxewvWBR 6dWkIT418MlcDDDGcMVQHRpkBmGnRKgdDwmtWwkra83QV29gy6yYZ3mJlttAWMSqdnnW6rS ur2RqgjHHFdBa6OrARdiQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Agjak8wRs4M=:p1dejvjKH9pcUnV0Y0PeDh A+SH02GSHVYBhowkDThzkT/qFilI1M47Q20SeM4pMFlObDcsnOvD1a8NkxilGkret6leF9mpF qQuMmG4CYCS3CapAeo9aMJW6Sa5ly5+NLlnjzTfKFR4qY+P+ckVixAr05lcqrfJxKvHVAoY52 SYX5NBjtAVPXbiU0P8KuX/MdWM26cKtoK4wfdP2HkHXacSDdILA44jnQqpWzyAWfCegtM9J1Z fXNXJGp9x3Lx6KOKIa1/EcF7B5Ffsc+QbWETK9DRbMYt+0xH4e4rnAAaYvGZ9cetCWyJlGTXN thnoly6SbGshuvh7VClpmYBIsmqyuV35ElGCIdVegMptICxma3v2MH+1GV0dd2NOw7Gkgzxeo koZ5mDtWDfAxM9Am32vksaKrsAKt9/6qqh1jCFKBINWWiT8T+feUgOo6rhN54a6IplusSMk/Y /7iSdVNMb8MG91Oi0RCOo9nO2GlpGvmEvGWKrupWN1y6SFuEBrQ5Irdm1w9KL6iE30ctOvtvg Y5TC+n3d903KMIeoL0V8AsckCK7Kht7x2J/jqFZnx6O2gWL7Mvk4I/y9Xx46ZE0l/sRwgeuy/ 72xi4ffsa3jm7TsQVQlutGBEa3jMpZzSPv0wMuKAapz3yFdey1LAJZNVaoga25N/hs45SaMoo nnvgMktxYk0+a/RTN7mForH6wslWVPP0EJIW1H3hTubmDNDsxYy9Wi2SqU2dD6PpcN3Fl7JwM 4RQm//HURZjgDKuJpWYGHVJATe0006yd8l5147Pjg5fOtzbjHEIfGqaKAlFvJVw/hSI3Sp3Og SoSyeR7 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: Mon, 24 Apr 2017 19:25:29 +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". This issue was detected by using the Coccinelle software. * 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/hid/hid-sensor-hub.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 4ef73374a8f9..349494fc8def 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -672,9 +672,11 @@ static int sensor_hub_probe(struct hid_device *hdev, ret = -EINVAL; goto err_stop_hw; } - sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt * - sizeof(struct mfd_cell), - GFP_KERNEL); + sd->hid_sensor_hub_client_devs + = devm_kcalloc(&hdev->dev, + dev_cnt, + sizeof(*sd->hid_sensor_hub_client_devs), + GFP_KERNEL); if (sd->hid_sensor_hub_client_devs == NULL) { hid_err(hdev, "Failed to allocate memory for mfd cells\n"); ret = -ENOMEM;