From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Sasha Levin <sashal@kernel.org>,
anarsoul@gmail.com, tiny.windzz@gmail.com, rafael@kernel.org,
wens@csie.org, samuel@sholland.org, linux-pm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev
Subject: [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it
Date: Fri, 8 Sep 2023 21:12:54 -0400 [thread overview]
Message-ID: <20230909011254.3581788-6-sashal@kernel.org> (raw)
In-Reply-To: <20230909011254.3581788-1-sashal@kernel.org>
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
next prev parent reply other threads:[~2023-09-09 1:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-09 1:12 [PATCH AUTOSEL 6.5 1/6] printk: Reduce console_unblank() usage in unsafe scenarios Sasha Levin
2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 2/6] printk: Keep non-panic-CPUs out of console lock Sasha Levin
2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 3/6] printk: Do not take console lock for console_flush_on_panic() Sasha Levin
2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 4/6] printk: Consolidate console deferred printing Sasha Levin
2023-09-09 1:12 ` [PATCH AUTOSEL 6.5 5/6] printk: Rename abandon_console_lock_in_panic() to other_cpu_in_panic() Sasha Levin
2023-09-09 1:12 ` Sasha Levin [this message]
2023-09-09 12:37 ` [PATCH AUTOSEL 6.5 6/6] thermal/drivers/sun8i: Free calibration nvmem after reading it Mark Brown
2023-09-18 17:28 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230909011254.3581788-6-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=anarsoul@gmail.com \
--cc=broonie@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=samuel@sholland.org \
--cc=stable@vger.kernel.org \
--cc=tiny.windzz@gmail.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox