Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: fix RTC removal

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

-1
-1
drivers/rtc/class.c
··· 335 335 cdev_device_del(&rtc->char_dev, &rtc->dev); 336 336 rtc->ops = NULL; 337 337 mutex_unlock(&rtc->ops_lock); 338 - put_device(&rtc->dev); 339 338 } 340 339 341 340 static void devm_rtc_release_device(void *res)