Skip to content

Commit 585dbb5

Browse files
Yuuoniygregkh
authored andcommitted
net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
[ Upstream commit 1e5a541 ] 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: 98c485e ("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: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7b240a8 commit 585dbb5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/phy/mediatek-ge-soc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,9 @@ static int mt798x_phy_calibration(struct phy_device *phydev)
10821082
}
10831083

10841084
buf = (u32 *)nvmem_cell_read(cell, &len);
1085+
nvmem_cell_put(cell);
10851086
if (IS_ERR(buf))
10861087
return PTR_ERR(buf);
1087-
nvmem_cell_put(cell);
10881088

10891089
if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) {
10901090
phydev_err(phydev, "invalid efuse data\n");

0 commit comments

Comments
 (0)