Commit 99a049aa authored by Bryan Brattlof's avatar Bryan Brattlof Committed by Daniel Lezcano

thermal/drivers/k3_j72xx_bandgap: Fix ref_table memory leak during probe

If an error occurs in the k3_j72xx_bandgap_probe() function the memory
allocated to the 'ref_table' will not be released.

Add a err_free_ref_table step to the error path to free 'ref_table'

Fixes: 72b3fc61c752 ("thermal: k3_j72xx_bandgap: Add the bandgap driver support")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarBryan Brattlof <bb@ti.com>
Reviewed-by: default avatarKeerthy <j-keerthy@ti.com>
Link: https://lore.kernel.org/r/20220525213617.30002-1-bb@ti.comSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 4102c404
No related merge requests found
......@@ -433,7 +433,7 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
GFP_KERNEL);
if (!derived_table) {
ret = -ENOMEM;
goto err_alloc;
goto err_free_ref_table;
}
/* Workaround not needed if bit30/bit31 is set even for J721e */
......@@ -483,7 +483,7 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
if (IS_ERR(ti_thermal)) {
dev_err(bgp->dev, "thermal zone device is NULL\n");
ret = PTR_ERR(ti_thermal);
goto err_alloc;
goto err_free_ref_table;
}
}
......@@ -514,6 +514,9 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
return 0;
err_free_ref_table:
kfree(ref_table);
err_alloc:
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment