]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
rtc: fix RTC removal
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Sat, 5 Dec 2020 23:14:48 +0000 (00:14 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 15 Dec 2020 23:33:33 +0000 (00:33 +0100)
Since the rtc_register_device, removing an RTC device will end with a
refcount_t: underflow; use-after-free warning since put_device is called
twice in the device tear down path.

Fixes: fdcfd854333b ("rtc: rework rtc_register_device() resource management")
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20201205231449.610980-1-alexandre.belloni@bootlin.com
drivers/rtc/class.c

index e6b44b7c4ad3ac3fa43eb73ca5aedfa3663a2233..5c6748dfa55df8d30fee56d5da9ca34384833e10 100644 (file)
@@ -335,7 +335,6 @@ static void devm_rtc_unregister_device(void *data)
        cdev_device_del(&rtc->char_dev, &rtc->dev);
        rtc->ops = NULL;
        mutex_unlock(&rtc->ops_lock);
-       put_device(&rtc->dev);
 }
 
 static void devm_rtc_release_device(void *res)