From: Mikko Perttunen Date: Wed, 11 Jul 2018 08:21:04 +0000 (+0300) Subject: clk: core: Potentially free connection id X-Git-Tag: Ubuntu-4.15.0-56.62~1909 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=c3beae995244d5faef880b6afb1150cc264dab98;p=mirror_ubuntu-bionic-kernel.git clk: core: Potentially free connection id BugLink: https://bugs.launchpad.net/bugs/1836117 [ Upstream commit 365f7a89c881e84f1ebc925f65f899d5d7ce547e ] 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 Reviewed-by: Leonard Crestez Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Kleber Sacilotto de Souza --- diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e08a18418908..434d6d6c7085 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2680,6 +2680,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(); @@ -3054,6 +3055,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; @@ -3075,6 +3077,7 @@ void __clk_put(struct clk *clk) module_put(owner); + kfree_const(clk->con_id); kfree(clk); }