]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 7 Jan 2026 01:03:14 +0000 (20:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Jan 2026 14:25:20 +0000 (15:25 +0100)
commit585dbb5cdbb8456f7a248b2c15951f9784dcdeb7
tree891b697e8dfc54644f59d0cfb8074e79f0dc855a
parent7b240a8935d554ad36a52c2c37c32039f9afaef2
net: phy: mediatek: fix nvmem cell reference leak in mt798x_phy_calibration

[ Upstream commit 1e5a541420b8c6d87d88eb50b6b978cdeafee1c9 ]

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: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/mediatek-ge-soc.c