From: SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
To: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Benjamin Tissoires"
<benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"Bruno Prémont"
<bonbons-ud5FBsm0p/xEiooADzr8i9i2O/JbrIOy@public.gmane.org>,
"Henrik Rydberg"
<rydberg-FFUHeuDi6mxAfugRpC6u6w@public.gmane.org>,
"Jiri Kosina" <jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Jonathan Cameron"
<jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Srinivas Pandruvada"
<srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/7] HID: sensor-hub: Use devm_kcalloc() in sensor_hub_probe()
Date: Mon, 24 Apr 2017 22:16:09 +0200 [thread overview]
Message-ID: <8a50aeac-0c9e-fff9-a7e7-61bcd733dfce@users.sourceforge.net> (raw)
In-Reply-To: <2d526d72-a740-367b-04a9-ed698435f8ed-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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 <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
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;
--
2.12.2
next prev parent reply other threads:[~2017-04-24 20:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-24 20:12 [PATCH 0/7] HID: Fine-tuning for some function implementations SF Markus Elfring
[not found] ` <2d526d72-a740-367b-04a9-ed698435f8ed-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-24 20:16 ` SF Markus Elfring [this message]
2017-04-24 20:17 ` [PATCH 2/7] HID: sensor-hub: Delete error messages for failed memory allocations in sensor_hub_probe() SF Markus Elfring
2017-04-27 18:16 ` SF Markus Elfring
2017-04-24 20:18 ` [PATCH 3/7] HID: sensor-hub: Adjust two checks for null pointers " SF Markus Elfring
2017-04-24 20:22 ` [PATCH 6/7] HID: debug: Combine two seq_printf() calls into one call in hid_dump_device() SF Markus Elfring
2017-04-24 20:23 ` [PATCH 7/7] HID: picoLCD: Replace two seq_printf() calls by seq_puts() in picolcd_debug_reset_show() SF Markus Elfring
2017-04-25 6:40 ` Bruno Prémont
2017-04-24 20:20 ` [PATCH 4/7] HID: debug: Replace five seq_printf() calls by seq_putc() SF Markus Elfring
2017-04-24 20:21 ` [PATCH 5/7] HID: debug: Replace 12 seq_printf() calls by seq_puts() SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a50aeac-0c9e-fff9-a7e7-61bcd733dfce@users.sourceforge.net \
--to=elfring-rn4veauk+akrv+lv9mx5uipxlwaovq5f@public.gmane.org \
--cc=benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=bonbons-ud5FBsm0p/xEiooADzr8i9i2O/JbrIOy@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rydberg-FFUHeuDi6mxAfugRpC6u6w@public.gmane.org \
--cc=srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).