From: Quanyang Wang
Use devm_kasprintf instead of kasprintf to fix the following kmemleak:
unreferenced object 0xff8803ed7280 (size 128):
comm "kworker/u8:1", pid 11, jiffies 4294892718 (age 234.496s)
hex dump (first 32 bytes):
38 30 30 31 30 30 30 30 2e 63 6c 6b 5f 77 69 7a 8001.clk_wiz
5f 6f 75 74 30 00 00 00 00 00 00 00 00 00 00 00 _out0...
backtrace:
[] __kmem_cache_alloc_node+0x3fc/0x5f0
[] __kmalloc_node_track_caller+0x5c/0x228
[<68e52a86>] kvasprintf+0x8c/0x118
[] kasprintf+0x5c/0x88
[<934884a9>] clk_wzrd_probe+0x374/0x730
[<167096d4>] platform_probe+0x70/0xe0
[] really_probe+0xc4/0x2b0
[<5eafe737>] __driver_probe_device+0x80/0x120
[<26f774f1>] driver_probe_device+0x48/0xf0
[<9bed11ed>] __device_attach_driver+0xc0/0x100
[<12782b09>] bus_for_each_drv+0x80/0xd8
[<08a5cc26>] __device_attach+0x104/0x198
[] device_initial_probe+0x1c/0x28
[] bus_probe_device+0xa4/0xb0
[<191df268>] deferred_probe_work_func+0x90/0xc8
[] process_one_work+0x1f4/0x460
Signed-off-by: Quanyang Wang
---
Hi Bruce,
Would you please help merge this patch to the branches:
v6.1/standard/preempt-rt/sdkv6.1/xlnx-soc
v6.1/standard/sdkv6.1/xlnx-soc
Thanks,
Quanyang
---
drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 12 +---
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
index e68be24a26e9d..4391eced19793 100644
--- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
+++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
@@ -645,7 +645,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
goto err_disable_clk;
}
- clkout_name = kasprintf(GFP_KERNEL, "%s_out0", dev_name(&pdev->dev));
+ clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out0",
dev_name(&pdev->dev));
if (nr_outputs == 1) {
clk_wzrd->clkout[0] = clk_wzrd_register_divider
(&pdev->dev, clkout_name,
@@ -666,7 +666,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
reg = reg & WZRD_CLKFBOUT_MULT_MASK;
reg = reg >> WZRD_CLKFBOUT_MULT_SHIFT;
mult = (reg * 1000) + reg_f;
- clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
+ clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul",
dev_name(&pdev->dev));
if (!clk_name) {
ret = -ENOMEM;
goto err_disable_clk;
@@ -675,14 +675,13 @@ static int clk_wzrd_probe(struct platform_device *pdev)
(&pdev->dev, clk_name,
__clk_get_name(clk_wzrd->clk_in1),
0, mult, 1000);
- kfree(clk_name);
if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul])) {
dev_err(&pdev->dev, "unable to register fixed-factor clock\n");
ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul]);
goto err_disable_clk;
}
- clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
+ clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul_div",
dev_name(&pdev->dev));
if (!clk_name) {
ret = -ENOMEM;
goto err_rm_int_clk;
@@ -703,7 +702,8 @@ static int clk_wzrd_probe(struct platform_device *pdev)
/* register div per output */
for (i = nr_outputs - 1; i >= 0 ; i--) {
- clkout_name = kasprintf(GFP_KERNEL, "%s_out%d",
dev_name(&pdev->dev), i);
+ clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out%d",
+ dev_name(&pdev->dev), i);
if (!clkout_name) {
ret = -ENOMEM;
goto err_rm_int_clk;
@@ -739,7 +739,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
}
- kfree(clk_name);
out:
clk_wzrd->clk_data.clks = clk_wzrd->clkout;
clk_wzrd->clk_data.clk_num = ARRAY_SIZE(clk_wzrd->clkout);
@@ -765,7 +764,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
err_rm_int_clks:
clk_unregister(clk_wzrd->clks_internal[1]);
err_rm_int_clk:
- kfree(clk_name);
clk_unregister(clk_wzrd->clks_internal[0]);
err_disable_clk:
clk_disable_unprepare(clk_wzrd->axi_clk);
--
2.36.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13620):
https://lists.yoctoproject.org/g/linux-yocto/message/13620
Mute This Topic: https://lists.yoctoproject.org/mt/104660586/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[arch...@mail-archive.com]
-=-=-=-=-