[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20190527140426.GA6078@zhanggen-UX430UQ>
Date: Mon, 27 May 2019 22:04:26 +0800
From: Gen Zhang <blackgod016574@...il.com>
To: mturquette@...libre.com, sboyd@...nel.org
Cc: linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] clk: fix a missing-free bug in clk_cpy_name()
In clk_cpy_name(), '*dst_p'('parent->name'and 'parent->fw_name') and
'dst' are allcoted by kstrdup_const(). According to doc: "Strings
allocated by kstrdup_const should be freed by kfree_const". So
'parent->name', 'parent->fw_name' and 'dst' should be freed.
Signed-off-by: Gen Zhang <blackgod016574@...il.com>
---
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index aa51756..85c4d3f 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3435,6 +3435,7 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist)
if (!dst)
return -ENOMEM;
+ kfree_const(dst);
return 0;
}
@@ -3491,6 +3492,8 @@ static int clk_core_populate_parent_map(struct clk_core *core)
kfree_const(parents[i].name);
kfree_const(parents[i].fw_name);
} while (--i >= 0);
+ kfree_const(parent->name);
+ kfree_const(parent->fw_name);
kfree(parents);
return ret;
---
Powered by blists - more mailing lists