mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ARM: imx: Check return value of devm_kasprintf in imx_mmdc_perf_init
[ Upstream commit 1c2b1049af3f86545fcc5fae0fc725fb64b3a09e ]
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.
Release the id allocated in 'mmdc_pmu_init' when 'devm_kasprintf'
return NULL
Suggested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Fixes: e76bdfd740
("ARM: imx: Added perf functionality to mmdc driver")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3836f1f246
commit
12deaef0c8
1 changed files with 6 additions and 1 deletions
|
@ -501,6 +501,10 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
|
||||||
|
|
||||||
name = devm_kasprintf(&pdev->dev,
|
name = devm_kasprintf(&pdev->dev,
|
||||||
GFP_KERNEL, "mmdc%d", ret);
|
GFP_KERNEL, "mmdc%d", ret);
|
||||||
|
if (!name) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto pmu_release_id;
|
||||||
|
}
|
||||||
|
|
||||||
pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
|
pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
|
||||||
pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
|
pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
|
||||||
|
@ -523,9 +527,10 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
|
||||||
|
|
||||||
pmu_register_err:
|
pmu_register_err:
|
||||||
pr_warn("MMDC Perf PMU failed (%d), disabled\n", ret);
|
pr_warn("MMDC Perf PMU failed (%d), disabled\n", ret);
|
||||||
ida_simple_remove(&mmdc_ida, pmu_mmdc->id);
|
|
||||||
cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
|
cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
|
||||||
hrtimer_cancel(&pmu_mmdc->hrtimer);
|
hrtimer_cancel(&pmu_mmdc->hrtimer);
|
||||||
|
pmu_release_id:
|
||||||
|
ida_simple_remove(&mmdc_ida, pmu_mmdc->id);
|
||||||
pmu_free:
|
pmu_free:
|
||||||
kfree(pmu_mmdc);
|
kfree(pmu_mmdc);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue