* [PATCH] phy: sunplus: Fix a memory leak in update_disc_vol()
@ 2024-01-28 8:47 Christophe JAILLET
2024-01-30 17:10 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-01-28 8:47 UTC (permalink / raw)
To: Vincent Shih, Vinod Koul, Kishon Vijay Abraham I
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-usb, linux-phy
'otp_v', allocated by nvmem_cell_read(), is leaking.
It must be freed before leaving the function to avoid a leak.
Fixes: 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative and based on comparison on the usage of
nvmem_cell_read() in other driver.
Review with care.
---
drivers/phy/sunplus/phy-sunplus-usb2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
index 637a5fbae6d9..50f1f91ac052 100644
--- a/drivers/phy/sunplus/phy-sunplus-usb2.c
+++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
@@ -105,6 +105,8 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
val = (val & ~J_DISC) | set;
writel(val, usbphy->phy_regs + CONFIG7);
+ kfree(otp_v);
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] phy: sunplus: Fix a memory leak in update_disc_vol()
2024-01-28 8:47 [PATCH] phy: sunplus: Fix a memory leak in update_disc_vol() Christophe JAILLET
@ 2024-01-30 17:10 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2024-01-30 17:10 UTC (permalink / raw)
To: Christophe JAILLET, Srinivas Kandagatla
Cc: Vincent Shih, Kishon Vijay Abraham I, linux-kernel,
kernel-janitors, linux-usb, linux-phy
On 28-01-24, 09:47, Christophe JAILLET wrote:
> 'otp_v', allocated by nvmem_cell_read(), is leaking.
> It must be freed before leaving the function to avoid a leak.
>
> Fixes: 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative and based on comparison on the usage of
> nvmem_cell_read() in other driver.
>
> Review with care.
> ---
> drivers/phy/sunplus/phy-sunplus-usb2.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
> index 637a5fbae6d9..50f1f91ac052 100644
> --- a/drivers/phy/sunplus/phy-sunplus-usb2.c
> +++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
> @@ -105,6 +105,8 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
> val = (val & ~J_DISC) | set;
> writel(val, usbphy->phy_regs + CONFIG7);
>
> + kfree(otp_v);
Looking at documentation, this should be nvmem_cell_put() see:
Documentation/driver-api/nvmem.rst
What do you suggest Srini?
> +
> return 0;
> }
>
> --
> 2.43.0
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-30 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 8:47 [PATCH] phy: sunplus: Fix a memory leak in update_disc_vol() Christophe JAILLET
2024-01-30 17:10 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).