diff options
| author | Wen Yang <wen.yang99@zte.com.cn> | 2019-04-16 22:43:02 -0400 |
|---|---|---|
| committer | Sebastian Reichel <sre@kernel.org> | 2019-04-17 16:14:24 -0400 |
| commit | 0b646fd1b1963bf44fe81853e89f3469aeb94a6c (patch) | |
| tree | 23dfddf5129e2a7710ff24cc84648a75ed6aae03 | |
| parent | 7d90fcc14a25b1ba715427f2af706809bb56a6f4 (diff) | |
power: supply: ab8500: fix leaked of_node refs in ab8500_bm_of_probe
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
492 int ab8500_bm_of_probe(struct device *dev,
493 struct device_node *np,
494 struct abx500_bm_data *bm)
495 {
496 const struct batres_vs_temp *tmp_batres_tbl;
497 struct device_node *battery_node;
...
501 /* get phandle to 'battery-info' node */
502 battery_node = of_parse_phandle(np, "battery", 0);
...
509 if (!btech) {
510 dev_warn(dev, "missing property battery-name/type\n");
511 return -EINVAL; ---> leaked here
512 }
...
540 of_node_put(battery_node); ---> released here
541
542 return 0;
543 }
Detected by coccinelle with the following warnings:
./drivers/power/supply/ab8500_bmdata.c:511:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 502, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| -rw-r--r-- | drivers/power/supply/ab8500_bmdata.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c index 7b2b69916f48..f6a66979cbb5 100644 --- a/drivers/power/supply/ab8500_bmdata.c +++ b/drivers/power/supply/ab8500_bmdata.c | |||
| @@ -508,6 +508,7 @@ int ab8500_bm_of_probe(struct device *dev, | |||
| 508 | btech = of_get_property(battery_node, "stericsson,battery-type", NULL); | 508 | btech = of_get_property(battery_node, "stericsson,battery-type", NULL); |
| 509 | if (!btech) { | 509 | if (!btech) { |
| 510 | dev_warn(dev, "missing property battery-name/type\n"); | 510 | dev_warn(dev, "missing property battery-name/type\n"); |
| 511 | of_node_put(battery_node); | ||
| 511 | return -EINVAL; | 512 | return -EINVAL; |
| 512 | } | 513 | } |
| 513 | 514 | ||
