Skip to contentSkip to conversation

power: supply: core: Delete two error messages for a failed memory allocation in power_supply_check_supplies()

PATCH In review SF Markus Elfring 2 participants 2 messages Aug 26, 2017 – Aug 29, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: core: Delete two error messages for a failed memory allocation in power_supply_check_supplies()

From: Markus Elfring <[email protected]>
Date: Sat, 26 Aug 2017 19:22:32 +0200

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/power/supply/power_supply_core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/power/supply/power_supply_core.c +2 -6
index 540d3e0aa011..3d46863baa52 100644
@@ -259,18 +259,14 @@ static int power_supply_check_supplies(struct power_supply *psy)
 	/* All supplies found, allocate char ** array for filling */
 	psy->supplied_from = devm_kzalloc(&psy->dev, sizeof(psy->supplied_from),
 					  GFP_KERNEL);
-	if (!psy->supplied_from) {
-		dev_err(&psy->dev, "Couldn't allocate memory for supply list\n");
+	if (!psy->supplied_from)
 		return -ENOMEM;
-	}
 
 	*psy->supplied_from = devm_kzalloc(&psy->dev,
 					   sizeof(char *) * (cnt - 1),
 					   GFP_KERNEL);
-	if (!*psy->supplied_from) {
-		dev_err(&psy->dev, "Couldn't allocate memory for supply list\n");
+	if (!*psy->supplied_from)
 		return -ENOMEM;
-	}
 
 	return power_supply_populate_supplied_from(psy);
 }
Signature · 1 line
2.14.0
#1 lore raw

Hi,

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 26 Aug 2017 19:22:32 +0200

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---

Thanks, queued.

-- Sebastian

Quoted 31 lines
 drivers/power/supply/power_supply_core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/power/supply/power_supply_core.c +2 -6
index 540d3e0aa011..3d46863baa52 100644
@@ -259,18 +259,14 @@ static int power_supply_check_supplies(struct power_supply *psy)
 	/* All supplies found, allocate char ** array for filling */
 	psy->supplied_from = devm_kzalloc(&psy->dev, sizeof(psy->supplied_from),
 					  GFP_KERNEL);
-	if (!psy->supplied_from) {
-		dev_err(&psy->dev, "Couldn't allocate memory for supply list\n");
+	if (!psy->supplied_from)
 		return -ENOMEM;
-	}
 
 	*psy->supplied_from = devm_kzalloc(&psy->dev,
 					   sizeof(char *) * (cnt - 1),
 					   GFP_KERNEL);
-	if (!*psy->supplied_from) {
-		dev_err(&psy->dev, "Couldn't allocate memory for supply list\n");
+	if (!*psy->supplied_from)
 		return -ENOMEM;
-	}
 
 	return power_supply_populate_supplied_from(psy);
 }
Signature · 1 line
2.14.0