]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: fix resource leak for drivers without .remove callback
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 19 Nov 2020 16:16:02 +0000 (17:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:25:55 +0000 (11:25 +0100)
commitd85ed98f5a91acb93b23b0e648f9c5c8fb426f14
treeefc5786b2160ca59a7ef65f6212e6da8954239db
parentad16a80015ea90dac6410277202972a913749957
spi: fix resource leak for drivers without .remove callback

[ Upstream commit 440408dbadfe47a615afd0a0a4a402e629be658a ]

Consider an spi driver with a .probe but without a .remove callback (e.g.
rtc-ds1347). The function spi_drv_probe() is called to bind a device and
so dev_pm_domain_attach() is called. As there is no remove callback
spi_drv_remove() isn't called at unbind time however and so calling
dev_pm_domain_detach() is missed and the pm domain keeps active.

To fix this always use both spi_drv_probe() and spi_drv_remove() and
make them handle the respective callback not being set. This has the
side effect that for a (hypothetical) driver that has neither .probe nor
remove the clk and pm domain setup is done.

Fixes: 33cf00e57082 ("spi: attach/detach SPI device to the ACPI power domain")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20201119161604.2633521-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi.c