Skip to content

Commit

Permalink
power: supply: olpc_battery: Hold the reference returned by of_find_c…
Browse files Browse the repository at this point in the history
…ompatible_node

In olpc_battery_probe(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put() for
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
  • Loading branch information
Liang He authored and Sebastian Reichel committed Jul 16, 2022
1 parent 38d4544 commit c9d8468
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/power/supply/olpc_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ static int olpc_battery_probe(struct platform_device *pdev)
struct power_supply_config bat_psy_cfg = {};
struct power_supply_config ac_psy_cfg = {};
struct olpc_battery_data *data;
struct device_node *np;
uint8_t status;
uint8_t ecver;
int ret;
Expand All @@ -649,7 +650,9 @@ static int olpc_battery_probe(struct platform_device *pdev)
if (ret)
return ret;

if (of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")) {
np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec");
if (np) {
of_node_put(np);
/* XO 1.75 */
data->new_proto = true;
data->little_endian = true;
Expand Down

0 comments on commit c9d8468

Please sign in to comment.