From: Markus Elfring <[email protected]>
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 <[email protected]>
---
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
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel