From: SF Markus Elfring <elfring@users.sourceforge.net>
To: devel@driverdev.osuosl.org, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Johan Hovold <johan@kernel.org>,
Rui Miguel Silva <rmfrfs@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 4/4] staging: greybus: power_supply: Use kcalloc() in gb_power_supplies_setup()
Date: Fri, 9 Dec 2016 15:40:24 +0100 [thread overview]
Message-ID: <3d6e0e13-b74d-f022-3edc-1bf1ae6ef9ac@users.sourceforge.net> (raw)
In-Reply-To: <a2db1eee-eb2c-07b6-2144-3e262facbef9@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 9 Dec 2016 15:04:24 +0100
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "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.
Fixes: ffe2e2487a388cf01ec44439346363aa8d654cd4 ("greybus: power_supply: rework and operation changes")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/greybus/power_supply.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
index e85c988b7034..19080c7f1491 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -944,10 +944,9 @@ static int gb_power_supplies_setup(struct gb_power_supplies *supplies)
if (ret < 0)
goto out;
- supplies->supply = kzalloc(supplies->supplies_count *
- sizeof(struct gb_power_supply),
- GFP_KERNEL);
-
+ supplies->supply = kcalloc(supplies->supplies_count,
+ sizeof(*supplies->supply),
+ GFP_KERNEL);
if (!supplies->supply) {
ret = -ENOMEM;
goto out;
--
2.11.0
next prev parent reply other threads:[~2016-12-09 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-09 14:32 [PATCH 0/4] staging-greybus: Fine-tuning for four functions SF Markus Elfring
2016-12-09 14:34 ` [PATCH 1/4] staging: greybus: camera: One function call less in gb_camera_configure_streams() after error detection SF Markus Elfring
2016-12-09 14:36 ` [PATCH 2/4] staging: greybus: light: Use kcalloc() in two functions SF Markus Elfring
2016-12-09 14:37 ` [PATCH 3/4] staging: greybus: light: Check return value of a kstrndup() call in gb_lights_light_config() SF Markus Elfring
2016-12-09 14:40 ` SF Markus Elfring [this message]
2016-12-09 14:53 ` [PATCH 0/4] staging-greybus: Fine-tuning for four functions Greg Kroah-Hartman
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=3d6e0e13-b74d-f022-3edc-1bf1ae6ef9ac@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=devel@driverdev.osuosl.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmfrfs@gmail.com \
/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
all inboxes | Powered by JetHome®