mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-13 04:39:36 +02:00
cpufreq: qcom-nvmem: fix memory leaks in probe error paths
[ Upstream commitd01c84b97f
] The code refactoring added new error paths between the np device node allocation and the call to of_node_put(), which leads to memory leaks if any of those errors occur. Add the missing of_node_put() in the error paths that require it. Cc: stable@vger.kernel.org Fixes:57f2f8b4aa
("cpufreq: qcom: Refactor the driver to make it easier to extend") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
51a45209a8
commit
e3fd01a810
|
@ -249,23 +249,30 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()),
|
drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!drv)
|
if (!drv) {
|
||||||
|
of_node_put(np);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
match = pdev->dev.platform_data;
|
match = pdev->dev.platform_data;
|
||||||
drv->data = match->data;
|
drv->data = match->data;
|
||||||
if (!drv->data)
|
if (!drv->data) {
|
||||||
|
of_node_put(np);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
if (drv->data->get_version) {
|
if (drv->data->get_version) {
|
||||||
speedbin_nvmem = of_nvmem_cell_get(np, NULL);
|
speedbin_nvmem = of_nvmem_cell_get(np, NULL);
|
||||||
if (IS_ERR(speedbin_nvmem))
|
if (IS_ERR(speedbin_nvmem)) {
|
||||||
|
of_node_put(np);
|
||||||
return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
|
return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
|
||||||
"Could not get nvmem cell\n");
|
"Could not get nvmem cell\n");
|
||||||
|
}
|
||||||
|
|
||||||
ret = drv->data->get_version(cpu_dev,
|
ret = drv->data->get_version(cpu_dev,
|
||||||
speedbin_nvmem, &pvs_name, drv);
|
speedbin_nvmem, &pvs_name, drv);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
of_node_put(np);
|
||||||
nvmem_cell_put(speedbin_nvmem);
|
nvmem_cell_put(speedbin_nvmem);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user