diff options
author | Nishka Dasgupta <nishkadg.linux@gmail.com> | 2019-08-19 09:27:06 +0200 |
---|---|---|
committer | Kevin Hilman <khilman@baylibre.com> | 2019-08-20 23:53:33 +0200 |
commit | 49ed86f503be80aac158a567c4cfd31cf1cd181e (patch) | |
tree | 2c9c2f68ac5afd2e729703bbe81b91e0eeb0e636 | |
parent | soc: amlogic: clk-measure: Add support for SM1 (diff) | |
download | linux-49ed86f503be80aac158a567c4cfd31cf1cd181e.tar.xz linux-49ed86f503be80aac158a567c4cfd31cf1cd181e.zip |
soc: amlogic: meson-gx-socinfo: Add of_node_put() before return
The variable np in function meson_gx_socinfo_init takes the return value
of of_find_compatible_node, which gets a node but does not put it. If
this node is not put it may cause a memory leak. Hence put np after its
usefulness has been exhausted.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Fixes: a9daaba2965e ("soc: Add Amlogic SoC Information driver")
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
-rw-r--r-- | drivers/soc/amlogic/meson-gx-socinfo.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c index b9f4c6f4fd03..6d0d04f163cb 100644 --- a/drivers/soc/amlogic/meson-gx-socinfo.c +++ b/drivers/soc/amlogic/meson-gx-socinfo.c @@ -141,8 +141,10 @@ static int __init meson_gx_socinfo_init(void) } /* check if chip-id is available */ - if (!of_property_read_bool(np, "amlogic,has-chip-id")) + if (!of_property_read_bool(np, "amlogic,has-chip-id")) { + of_node_put(np); return -ENODEV; + } /* node should be a syscon */ regmap = syscon_node_to_regmap(np); |