linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Free struct clk allocated during clk_hw_register()
@ 2016-11-08  8:23 Rajendra Nayak
  2016-11-08  9:36 ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Rajendra Nayak @ 2016-11-08  8:23 UTC (permalink / raw)
  To: sboyd, mturquette; +Cc: linux-clk, linux-kernel, Rajendra Nayak

With clk_hw_register() API we hide the struct clk from the caller
and return an int error code instead, so the caller (clk provider)
is not expected to use hw->clk on return.
Free the memory, and mark hw->clk as NULL before returning.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/clk/clk.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 0fb39fe..f81e4aa 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2628,7 +2628,15 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
  */
 int clk_hw_register(struct device *dev, struct clk_hw *hw)
 {
-	return PTR_ERR_OR_ZERO(clk_register(dev, hw));
+	struct clk *c;
+
+	c = clk_register(dev, hw);
+	if (IS_ERR(c))
+		return PTR_ERR(c);
+
+	__clk_free_clk(c);
+	hw->clk = NULL;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(clk_hw_register);
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

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

end of thread, other threads:[~2016-11-08 10:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-08  8:23 [PATCH] clk: Free struct clk allocated during clk_hw_register() Rajendra Nayak
2016-11-08  9:36 ` Geert Uytterhoeven
2016-11-08 10:04   ` Rajendra Nayak
2016-11-08 10:37     ` Rajendra Nayak

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).