Skip to content

Commit d01c84b

Browse files
javiercarrascocruzvireshk
authored andcommitted
cpufreq: qcom-nvmem: fix memory leaks in probe error paths
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: [email protected] Fixes: 57f2f8b ("cpufreq: qcom: Refactor the driver to make it easier to extend") Signed-off-by: Javier Carrasco <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 074cffb commit d01c84b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,30 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
480480

481481
drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()),
482482
GFP_KERNEL);
483-
if (!drv)
483+
if (!drv) {
484+
of_node_put(np);
484485
return -ENOMEM;
486+
}
485487

486488
match = pdev->dev.platform_data;
487489
drv->data = match->data;
488-
if (!drv->data)
490+
if (!drv->data) {
491+
of_node_put(np);
489492
return -ENODEV;
493+
}
490494

491495
if (drv->data->get_version) {
492496
speedbin_nvmem = of_nvmem_cell_get(np, NULL);
493-
if (IS_ERR(speedbin_nvmem))
497+
if (IS_ERR(speedbin_nvmem)) {
498+
of_node_put(np);
494499
return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem),
495500
"Could not get nvmem cell\n");
501+
}
496502

497503
ret = drv->data->get_version(cpu_dev,
498504
speedbin_nvmem, &pvs_name, drv);
499505
if (ret) {
506+
of_node_put(np);
500507
nvmem_cell_put(speedbin_nvmem);
501508
return ret;
502509
}

0 commit comments

Comments
 (0)