Commit c51592a9 authored by Mark Brown's avatar Mark Brown Committed by Daniel Lezcano

thermal/drivers/sun8i: Free calibration nvmem after reading it

The sun8i thermal driver reads calibration data via the nvmem API at
startup, updating the device configuration and not referencing the data
again.  Rather than explicitly freeing the nvmem data the driver relies
on devm_ to release it, even though the data is never referenced again.
The allocation is still tracked so it's not leaked but this is notable
when looking at the code and is a little wasteful so let's instead
explicitly free the nvmem after we're done with it.
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Acked-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230719-thermal-sun8i-free-nvmem-v1-1-f553d5afef79@kernel.org
parent f664a6b5
...@@ -284,7 +284,7 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) ...@@ -284,7 +284,7 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
size_t callen; size_t callen;
int ret = 0; int ret = 0;
calcell = devm_nvmem_cell_get(dev, "calibration"); calcell = nvmem_cell_get(dev, "calibration");
if (IS_ERR(calcell)) { if (IS_ERR(calcell)) {
if (PTR_ERR(calcell) == -EPROBE_DEFER) if (PTR_ERR(calcell) == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
...@@ -314,6 +314,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) ...@@ -314,6 +314,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
kfree(caldata); kfree(caldata);
out: out:
if (!IS_ERR(calcell))
nvmem_cell_put(calcell);
return ret; return ret;
} }
......
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