diff options
author | Nishka Dasgupta <nishkadg.linux@gmail.com> | 2019-07-16 07:38:31 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-11-27 07:53:26 +0100 |
commit | bf9d46f751e75bf3d9a48bd69675f95d86ff7eb9 (patch) | |
tree | fcd86383f18cb487694d87adb7e53b244cd8b279 /drivers | |
parent | d0ac1a26ed5943127cb0156148735f5f52a07075 (diff) |
media: platform: sti: c8sectpfe: core: Add of_node_put() at goto
Each iteration of for_each_child_of_node puts the previous node, but in
the case of a goto from the middle of the loop, there is no put, thus
causing a memory leak. Hence add a new label that puts the last used
node, and edit the goto statements in the middle of the loop to first go
to the new label.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index dbe7788083a4..f0cbcb8a9677 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c @@ -765,7 +765,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) if (!fei->channel_data[index]) { ret = -ENOMEM; - goto err_clk_disable; + goto err_node_put; } tsin = fei->channel_data[index]; @@ -775,7 +775,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) ret = of_property_read_u32(child, "tsin-num", &tsin->tsin_id); if (ret) { dev_err(&pdev->dev, "No tsin_num found\n"); - goto err_clk_disable; + goto err_node_put; } /* sanity check value */ @@ -784,7 +784,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) "tsin-num %d specified greater than number\n\tof input block hw in SoC! (%d)", tsin->tsin_id, fei->hw_stats.num_ib); ret = -EINVAL; - goto err_clk_disable; + goto err_node_put; } tsin->invert_ts_clk = of_property_read_bool(child, @@ -800,14 +800,14 @@ static int c8sectpfe_probe(struct platform_device *pdev) &tsin->dvb_card); if (ret) { dev_err(&pdev->dev, "No dvb-card found\n"); - goto err_clk_disable; + goto err_node_put; } i2c_bus = of_parse_phandle(child, "i2c-bus", 0); if (!i2c_bus) { dev_err(&pdev->dev, "No i2c-bus found\n"); ret = -ENODEV; - goto err_clk_disable; + goto err_node_put; } tsin->i2c_adapter = of_find_i2c_adapter_by_node(i2c_bus); @@ -815,7 +815,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) dev_err(&pdev->dev, "No i2c adapter found\n"); of_node_put(i2c_bus); ret = -ENODEV; - goto err_clk_disable; + goto err_node_put; } of_node_put(i2c_bus); @@ -826,7 +826,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) dev_err(dev, "reset gpio for tsin%d not valid (gpio=%d)\n", tsin->tsin_id, tsin->rst_gpio); - goto err_clk_disable; + goto err_node_put; } ret = devm_gpio_request_one(dev, tsin->rst_gpio, @@ -834,7 +834,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) if (ret && ret != -EBUSY) { dev_err(dev, "Can't request tsin%d reset gpio\n" , fei->channel_data[index]->tsin_id); - goto err_clk_disable; + goto err_node_put; } if (!ret) { @@ -877,6 +877,8 @@ static int c8sectpfe_probe(struct platform_device *pdev) return 0; +err_node_put: + of_node_put(child); err_clk_disable: clk_disable_unprepare(fei->c8sectpfeclk); return ret; |