diff options
| author | Miaoqian Lin <linmq006@gmail.com> | 2025-12-11 12:13:13 +0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-08 10:17:14 +0100 |
| commit | 2431c1e4765a93f9358da530d54a5c20d3f5ed5a (patch) | |
| tree | 09e48c6acf0e4dd26add7a53906163187e04ec4d /drivers/net/phy | |
| parent | c9a8cd3ac85cdf5de80c8a45536974f4f6a64bbe (diff) | |
| download | linux-2431c1e4765a93f9358da530d54a5c20d3f5ed5a.tar.gz linux-2431c1e4765a93f9358da530d54a5c20d3f5ed5a.tar.bz2 linux-2431c1e4765a93f9358da530d54a5c20d3f5ed5a.zip | |
net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
commit 1e5a541420b8c6d87d88eb50b6b978cdeafee1c9 upstream.
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>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251211081313.2368460-1-linmq006@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/phy')
| -rw-r--r-- | drivers/net/phy/mediatek/mtk-ge-soc.c | 2 |
1 files changed, 1 insertions, 1 deletions
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"); |
