Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1539419
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/4] staging: greybus: power_supply: Use kcalloc() in gb_power_supplies_setup() |
| Date | 2016-12-09 15:50 +0100 |
| Message-ID | <sMuEO-4tz-15@gated-at.bofh.it> (permalink) |
| References | <sMuv7-4qd-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] staging-greybus: Fine-tuning for four functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-12-09 15:40 +0100 [PATCH 3/4] staging: greybus: light: Check return value of a kstrndup() call in gb_lights_light_config() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-12-09 15:40 +0100 [PATCH 2/4] staging: greybus: light: Use kcalloc() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-12-09 15:40 +0100 [PATCH 4/4] staging: greybus: power_supply: Use kcalloc() in gb_power_supplies_setup() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-12-09 15:50 +0100 Re: [PATCH 0/4] staging-greybus: Fine-tuning for four functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-12-09 16:00 +0100
csiph-web