Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration

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>

authored by

Miaoqian Lin and committed by
Paolo Abeni
1e5a5414 15ef641a

+1 -1
+1 -1
drivers/net/phy/mediatek/mtk-ge-soc.c
··· 1167 1167 } 1168 1168 1169 1169 buf = (u32 *)nvmem_cell_read(cell, &len); 1170 + nvmem_cell_put(cell); 1170 1171 if (IS_ERR(buf)) 1171 1172 return PTR_ERR(buf); 1172 - nvmem_cell_put(cell); 1173 1173 1174 1174 if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) { 1175 1175 phydev_err(phydev, "invalid efuse data\n");