Commit 9863a157 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Luis Henriques

power: bq2415x_charger: Fix memory leak on DTS parsing error

commit 21e863b2 upstream.

Memory allocated for 'name' was leaking if required binding properties
were not present.

The memory for 'name' was allocated early at probe with kasprintf(). It
was freed in error paths executed before and after parsing DTS but not
in that error path.

Fix the error path for parsing device tree properties.
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: faffd234 ("bq2415x_charger: Add DT support")
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent fe652189
......@@ -1609,27 +1609,27 @@ static int bq2415x_probe(struct i2c_client *client,
ret = of_property_read_u32(np, "ti,current-limit",
&bq->init_data.current_limit);
if (ret)
return ret;
goto error_2;
ret = of_property_read_u32(np, "ti,weak-battery-voltage",
&bq->init_data.weak_battery_voltage);
if (ret)
return ret;
goto error_2;
ret = of_property_read_u32(np, "ti,battery-regulation-voltage",
&bq->init_data.battery_regulation_voltage);
if (ret)
return ret;
goto error_2;
ret = of_property_read_u32(np, "ti,charge-current",
&bq->init_data.charge_current);
if (ret)
return ret;
goto error_2;
ret = of_property_read_u32(np, "ti,termination-current",
&bq->init_data.termination_current);
if (ret)
return ret;
goto error_2;
ret = of_property_read_u32(np, "ti,resistor-sense",
&bq->init_data.resistor_sense);
if (ret)
return ret;
goto error_2;
} else {
memcpy(&bq->init_data, pdata, sizeof(bq->init_data));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment