From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-input@vger.kernel.org,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Jiri Kosina <jikos@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions
Date: Tue, 25 Apr 2017 17:13:55 +0200 [thread overview]
Message-ID: <d0224def-26ba-d33b-e9be-a6218259c8e4@users.sourceforge.net> (raw)
In-Reply-To: <d126aeeb-f7e0-e54b-b874-61d776fe45cb@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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
next prev parent reply other threads:[~2017-04-25 15:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
2017-04-25 15:13 ` SF Markus Elfring [this message]
2017-06-05 15:29 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions Jason Gerecke
2017-04-25 15:14 ` [PATCH 2/3] HID: Wacom: Improve size determinations in three functions SF Markus Elfring
2017-04-25 15:15 ` [PATCH 3/3] HID: Wacom: Delete two unnecessary return statements SF Markus Elfring
2017-05-15 17:18 ` [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations Jason Gerecke
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=d0224def-26ba-d33b-e9be-a6218259c8e4@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).