linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: core: Potentially free connection id
@ 2018-07-11  8:21 Mikko Perttunen
  2018-07-11 10:17 ` Leonard Crestez
  2018-07-25 16:30 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Mikko Perttunen @ 2018-07-11  8:21 UTC (permalink / raw)
  To: mturquette, sboyd
  Cc: leonard.crestez, cyndis, linux-clk, linux-kernel, Mikko Perttunen

Patch "clk: core: Copy connection id" made it so that the connector
id (con_id) is kstrdup_const'ed to cater to drivers that pass non-
constant connection ids. The patch added the corresponding kfree_const
to __clk_free_clk, but struct clk's can be freed also via __clk_put.
Add the kfree_const call to __clk_put and add comments to both
functions to remind that the logic in them should be kept in sync.

Fixes: 253160a8ad06 ("clk: core: Copy connection id")
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ac96caab0523..d31055ae6ec6 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3132,6 +3132,7 @@ struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
 	return clk;
 }
 
+/* keep in sync with __clk_put */
 void __clk_free_clk(struct clk *clk)
 {
 	clk_prepare_lock();
@@ -3511,6 +3512,7 @@ int __clk_get(struct clk *clk)
 	return 1;
 }
 
+/* keep in sync with __clk_free_clk */
 void __clk_put(struct clk *clk)
 {
 	struct module *owner;
@@ -3544,6 +3546,7 @@ void __clk_put(struct clk *clk)
 
 	module_put(owner);
 
+	kfree_const(clk->con_id);
 	kfree(clk);
 }
 
-- 
2.16.1


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

* Re: [PATCH] clk: core: Potentially free connection id
  2018-07-11  8:21 [PATCH] clk: core: Potentially free connection id Mikko Perttunen
@ 2018-07-11 10:17 ` Leonard Crestez
  2018-07-25 16:30 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Leonard Crestez @ 2018-07-11 10:17 UTC (permalink / raw)
  To: mperttunen, mturquette, sboyd; +Cc: linux-kernel, cyndis, linux-clk

On Wed, 2018-07-11 at 11:21 +0300, Mikko Perttunen wrote:
> Patch "clk: core: Copy connection id" made it so that the connector
> id (con_id) is kstrdup_const'ed to cater to drivers that pass non-
> constant connection ids. The patch added the corresponding
> kfree_const
> to __clk_free_clk, but struct clk's can be freed also via __clk_put.
> Add the kfree_const call to __clk_put and add comments to both
> functions to remind that the logic in them should be kept in sync.
> 
> Fixes: 253160a8ad06 ("clk: core: Copy connection id")
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

Yes, sorry I missed this.

Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>

Maybe a static __clk_free_mem function could be created instead of
comments asking to keep things in sync? But there are only 2 lines so
it's fine.

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

* Re: [PATCH] clk: core: Potentially free connection id
  2018-07-11  8:21 [PATCH] clk: core: Potentially free connection id Mikko Perttunen
  2018-07-11 10:17 ` Leonard Crestez
@ 2018-07-25 16:30 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2018-07-25 16:30 UTC (permalink / raw)
  To: Mikko Perttunen, mturquette
  Cc: leonard.crestez, cyndis, linux-clk, linux-kernel, Mikko Perttunen

Quoting Mikko Perttunen (2018-07-11 01:21:04)
> Patch "clk: core: Copy connection id" made it so that the connector
> id (con_id) is kstrdup_const'ed to cater to drivers that pass non-
> constant connection ids. The patch added the corresponding kfree_const
> to __clk_free_clk, but struct clk's can be freed also via __clk_put.
> Add the kfree_const call to __clk_put and add comments to both
> functions to remind that the logic in them should be kept in sync.
> 
> Fixes: 253160a8ad06 ("clk: core: Copy connection id")
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---

Applied to clk-next


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

end of thread, other threads:[~2018-07-25 16:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11  8:21 [PATCH] clk: core: Potentially free connection id Mikko Perttunen
2018-07-11 10:17 ` Leonard Crestez
2018-07-25 16:30 ` Stephen Boyd

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