linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] clk: bcm2835: fix memork leak on unfree'd pll struct
@ 2019-06-07 10:45 Colin King
  2019-06-07 19:03 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-06-07 10:45 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Florian Fainelli, Ray Jui,
	Scott Branden, bcm-kernel-feedback-list, Eric Anholt,
	Stefan Wahren, linux-clk, linux-rpi-kernel, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The pll struct is being allocated but not kfree'd on an error return
path when devm_clk_hw_register fails.  Fix this with a kfree on pll
if an error occurs.

Addresses-Coverity: ("Resource leak")
Fixes: b19f009d4510 ("clk: bcm2835: Migrate to clk_hw based registration and OF APIs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/clk/bcm/clk-bcm2835.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 770bb01f523e..90584deaf416 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1310,8 +1310,10 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
 	pll->hw.init = &init;
 
 	ret = devm_clk_hw_register(cprman->dev, &pll->hw);
-	if (ret)
+	if (ret) {
+		kfree(pll);
 		return NULL;
+	}
 	return &pll->hw;
 }
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-08 22:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 10:45 [PATCH][next] clk: bcm2835: fix memork leak on unfree'd pll struct Colin King
2019-06-07 19:03 ` Stephen Boyd
2019-06-08 22:23   ` Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).