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>
This commit is contained in:
parent
8f5a37cb28
commit
f9c85486c4
1 changed files with 4 additions and 0 deletions
|
@ -226,6 +226,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
|
||||||
of_node_put(np);
|
of_node_put(np);
|
||||||
} while (np);
|
} while (np);
|
||||||
|
|
||||||
|
/* Missing valid "power-supplies" entries */
|
||||||
|
if (cnt == 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* All supplies found, allocate char ** array for filling */
|
/* 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);
|
GFP_KERNEL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue