]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
phylib: fix potential use-after-free
authorMarek Behún <kabel@kernel.org>
Wed, 19 Jan 2022 16:27:48 +0000 (17:27 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 29 Mar 2022 07:13:48 +0000 (09:13 +0200)
commit958add6c374014964f0551cf1f627f8f649cce49
tree920f037eef934e32cd7b7ba0f0e36efe763af193
parent3651e2cd6849405403805bac433b7105e1f60c92
phylib: fix potential use-after-free

BugLink: https://bugs.launchpad.net/bugs/1962345
[ Upstream commit cbda1b16687580d5beee38273f6241ae3725960c ]

Commit bafbdd527d56 ("phylib: Add device reset GPIO support") added call
to phy_device_reset(phydev) after the put_device() call in phy_detach().

The comment before the put_device() call says that the phydev might go
away with put_device().

Fix potential use-after-free by calling phy_device_reset() before
put_device().

Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20220119162748.32418-1-kabel@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/phy/phy_device.c