Skip to content

Commit c51592a

Browse files
brooniedlezcano
authored andcommitted
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: Mark Brown <broonie@kernel.org> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230719-thermal-sun8i-free-nvmem-v1-1-f553d5afef79@kernel.org
1 parent f664a6b commit c51592a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/thermal/sun8i_thermal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
284284
size_t callen;
285285
int ret = 0;
286286

287-
calcell = devm_nvmem_cell_get(dev, "calibration");
287+
calcell = nvmem_cell_get(dev, "calibration");
288288
if (IS_ERR(calcell)) {
289289
if (PTR_ERR(calcell) == -EPROBE_DEFER)
290290
return -EPROBE_DEFER;
@@ -314,6 +314,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
314314

315315
kfree(caldata);
316316
out:
317+
if (!IS_ERR(calcell))
318+
nvmem_cell_put(calcell);
317319
return ret;
318320
}
319321

0 commit comments

Comments
 (0)