]> git.baikalelectronics.ru Git - kernel.git/commit
net: fec: Better handle pm_runtime_get() failing in .remove()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 10 May 2023 20:00:20 +0000 (22:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:44:05 +0000 (12:44 +0100)
commita44b49a619f077d64a94833d7ac97f7dde4076ee
tree343c4728a39da37c608b9282f4052cb04b11685b
parent0b9d6aeb2a34cca79d113ac50d57eb3b85ecd02e
net: fec: Better handle pm_runtime_get() failing in .remove()

[ Upstream commit f816b9829b19394d318e01953aa3b2721bca040d ]

In the (unlikely) event that pm_runtime_get() (disguised as
pm_runtime_resume_and_get()) fails, the remove callback returned an
error early. The problem with this is that the driver core ignores the
error value and continues removing the device. This results in a
resource leak. Worse the devm allocated resources are freed and so if a
callback of the driver is called later the register mapping is already
gone which probably results in a crash.

Fixes: 4afc8a1b1593 ("net: fec: fix clock count mis-match")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20230510200020.1534610-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/fec_main.c