* [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it [not found] <20230909011254.3581788-1-sashal@kernel.org> @ 2023-09-09 1:12 ` Sasha Levin 2023-09-09 12:37 ` Mark Brown 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2023-09-09 1:12 UTC (permalink / raw) To: linux-kernel, stable Cc: Mark Brown, Jernej Skrabec, Daniel Lezcano, Sasha Levin, anarsoul, tiny.windzz, rafael, wens, samuel, linux-pm, linux-arm-kernel, linux-sunxi From: Mark Brown <broonie@kernel.org> [ Upstream commit c51592a95f360aabf2b8a5691c550e1749dc41eb ] 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 Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/thermal/sun8i_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 195f3c5d0b388..af3098717e3c1 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -286,7 +286,7 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) size_t callen; int ret = 0; - calcell = devm_nvmem_cell_get(dev, "calibration"); + calcell = nvmem_cell_get(dev, "calibration"); if (IS_ERR(calcell)) { if (PTR_ERR(calcell) == -EPROBE_DEFER) return -EPROBE_DEFER; @@ -316,6 +316,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) kfree(caldata); out: + if (!IS_ERR(calcell)) + nvmem_cell_put(calcell); return ret; } -- 2.40.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it 2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it Sasha Levin @ 2023-09-09 12:37 ` Mark Brown 2023-09-18 17:28 ` Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Mark Brown @ 2023-09-09 12:37 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Jernej Skrabec, Daniel Lezcano, anarsoul, tiny.windzz, rafael, wens, samuel, linux-pm, linux-arm-kernel, linux-sunxi, Greg Kroah-Hartman [-- Attachment #1.1: Type: text/plain, Size: 793 bytes --] On Fri, Sep 08, 2023 at 09:12:54PM -0400, Sasha Levin wrote: > From: Mark Brown <broonie@kernel.org> > > [ Upstream commit c51592a95f360aabf2b8a5691c550e1749dc41eb ] > > 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. This is a minor cleanup which as with so much of what's come in today's backports seems very questionable for stable. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 176 bytes --] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it 2023-09-09 12:37 ` Mark Brown @ 2023-09-18 17:28 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2023-09-18 17:28 UTC (permalink / raw) To: Mark Brown Cc: linux-kernel, stable, Jernej Skrabec, Daniel Lezcano, anarsoul, tiny.windzz, rafael, wens, samuel, linux-pm, linux-arm-kernel, linux-sunxi, Greg Kroah-Hartman On Sat, Sep 09, 2023 at 01:37:19PM +0100, Mark Brown wrote: >On Fri, Sep 08, 2023 at 09:12:54PM -0400, Sasha Levin wrote: >> From: Mark Brown <broonie@kernel.org> >> >> [ Upstream commit c51592a95f360aabf2b8a5691c550e1749dc41eb ] >> >> 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. > >This is a minor cleanup which as with so much of what's come in today's >backports seems very questionable for stable. I'll drop this, thanks! -- Thanks, Sasha _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-18 17:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230909011254.3581788-1-sashal@kernel.org>
2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it Sasha Levin
2023-09-09 12:37 ` Mark Brown
2023-09-18 17:28 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox