summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-09-04 17:31:23 +0530
committerSebastian Reichel <sre@kernel.org>2014-09-16 11:01:27 +0200
commitf9c85486c4ae8fd56770340bd9c16a61127c96e1 (patch)
treeafd50e87aa06851ed681f8adc498c52796b65cda /drivers/power
parent8f5a37cb28fce189f3d6802ade98a116f59a47bf (diff)
downloadlinux-f9c85486c4ae8fd56770340bd9c16a61127c96e1.tar.bz2
power-supply: Return early if "power-supplies" property isn't valid
If power-supply's DT node doesn't have a valid "power-supplies" entry, then power_supply_check_supplies() should return early instead of trying to allocate memory for "supplied_from" array. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/power_supply_core.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 10f0b57f00d9..414384a4ab52 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -226,6 +226,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
of_node_put(np);
} while (np);
+ /* Missing valid "power-supplies" entries */
+ if (cnt == 1)
+ return 0;
+
/* All supplies found, allocate char ** array for filling */
psy->supplied_from = devm_kzalloc(psy->dev, sizeof(psy->supplied_from),
GFP_KERNEL);