amba: Fix resource leak for drivers without .remove
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 26 Jan 2021 16:58:31 +0000 (17:58 +0100)
committerUwe Kleine-König <uwe@kleine-koenig.org>
Tue, 2 Feb 2021 13:24:10 +0000 (14:24 +0100)
commitde5d7adb89367bbc87b4e5ce7afe7ae9bd86dc12
tree10a06d1491cb98fff55be2cd83546d46001f8860
parent5c8fe583cce542aa0b84adc939ce85293de36e5e
amba: Fix resource leak for drivers without .remove

Consider an amba driver with a .probe but without a .remove callback (e.g.
pl061_gpio_driver). The function amba_probe() is called to bind a device
and so dev_pm_domain_attach() and others are called. As there is no remove
callback amba_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 the core driver callbacks and handle missing amba
callbacks there. For probe refuse registration as a driver without probe
doesn't make sense.

Fixes: 7cfe249475fd ("ARM: AMBA: Add pclk support to AMBA bus infrastructure")
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210126165835.687514-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/amba/bus.c