linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: Fix sizeof() mismatch
@ 2020-10-08 15:44 Colin King
  0 siblings, 0 replies; only message in thread
From: Colin King @ 2020-10-08 15:44 UTC (permalink / raw)
  To: Sebastian Reichel, Anton Vorontsov, Rhyland Klein, linux-pm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

An incorrect sizeof() is being used, sizeof(psy->supplied_from) is not
correct, it should be sizeof(*psy->supplied_from).  This bug did not
cause any issues because it just so happens the sizes are the same.

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: f6e0b081fb30 ("power_supply: Populate supplied_from hierarchy from the device tree")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/power/supply/power_supply_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 38e3aa642131..50f323740c74 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -261,7 +261,8 @@ static int power_supply_check_supplies(struct power_supply *psy)
 		return 0;
 
 	/* All supplies found, allocate char ** array for filling */
-	psy->supplied_from = devm_kzalloc(&psy->dev, sizeof(psy->supplied_from),
+	psy->supplied_from = devm_kzalloc(&psy->dev,
+					  sizeof(*psy->supplied_from),
 					  GFP_KERNEL);
 	if (!psy->supplied_from)
 		return -ENOMEM;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-08 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 15:44 [PATCH] power: supply: Fix sizeof() mismatch Colin King

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).