* [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
@ 2025-12-11 8:13 Miaoqian Lin
2025-12-11 11:05 ` Daniel Golle
2025-12-11 13:34 ` Andrew Lunn
0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2025-12-11 8:13 UTC (permalink / raw)
To: Daniel Golle, Qingfang Deng, SkyLake Huang, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: linmq006, stable
When nvmem_cell_read() fails in mt798x_phy_calibration(), the function
returns without calling nvmem_cell_put(), leaking the cell reference.
Move nvmem_cell_put() right after nvmem_cell_read() to ensure the cell
reference is always released regardless of the read result.
Found via static analysis and code review.
Fixes: 98c485eaf509 ("net: phy: add driver for MediaTek SoC built-in GE PHYs")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/net/phy/mediatek/mtk-ge-soc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
index cd09fbf92ef2..2c4bbc236202 100644
--- a/drivers/net/phy/mediatek/mtk-ge-soc.c
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
@@ -1167,9 +1167,9 @@ static int mt798x_phy_calibration(struct phy_device *phydev)
}
buf = (u32 *)nvmem_cell_read(cell, &len);
+ nvmem_cell_put(cell);
if (IS_ERR(buf))
return PTR_ERR(buf);
- nvmem_cell_put(cell);
if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) {
phydev_err(phydev, "invalid efuse data\n");
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
2025-12-11 8:13 [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration Miaoqian Lin
@ 2025-12-11 11:05 ` Daniel Golle
2025-12-11 13:34 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Golle @ 2025-12-11 11:05 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Qingfang Deng, SkyLake Huang, Andrew Lunn, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Thu, Dec 11, 2025 at 12:13:13PM +0400, Miaoqian Lin wrote:
> When nvmem_cell_read() fails in mt798x_phy_calibration(), the function
> returns without calling nvmem_cell_put(), leaking the cell reference.
>
> Move nvmem_cell_put() right after nvmem_cell_read() to ensure the cell
> reference is always released regardless of the read result.
>
> Found via static analysis and code review.
>
> Fixes: 98c485eaf509 ("net: phy: add driver for MediaTek SoC built-in GE PHYs")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
2025-12-11 8:13 [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration Miaoqian Lin
2025-12-11 11:05 ` Daniel Golle
@ 2025-12-11 13:34 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2025-12-11 13:34 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Daniel Golle, Qingfang Deng, SkyLake Huang, Heiner Kallweit,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Thu, Dec 11, 2025 at 12:13:13PM +0400, Miaoqian Lin wrote:
> When nvmem_cell_read() fails in mt798x_phy_calibration(), the function
> returns without calling nvmem_cell_put(), leaking the cell reference.
>
> Move nvmem_cell_put() right after nvmem_cell_read() to ensure the cell
> reference is always released regardless of the read result.
>
> Found via static analysis and code review.
>
> Fixes: 98c485eaf509 ("net: phy: add driver for MediaTek SoC built-in GE PHYs")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-11 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 8:13 [PATCH] net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration Miaoqian Lin
2025-12-11 11:05 ` Daniel Golle
2025-12-11 13:34 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox