From: Dmitry Torokhov Date: Mon, 20 Jul 2015 23:02:51 +0000 (-0700) Subject: rtc: dev: properly manage lifetime of dev and cdev in rtc device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1e4cd62558c293bc51cc179d676b708683a29c12;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git rtc: dev: properly manage lifetime of dev and cdev in rtc device struct rtc embeds both struct dev and struct cdev. Unfortunately character device structure may outlive the parent rtc structure unless we set it up as parent of character device so that it will stay pinned until character device is freed. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski Signed-off-by: Alexandre Belloni --- diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 799c34bcb26f..a6d9434addf6 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c @@ -477,6 +477,7 @@ void rtc_dev_prepare(struct rtc_device *rtc) cdev_init(&rtc->char_dev, &rtc_dev_fops); rtc->char_dev.owner = rtc->owner; + rtc->char_dev.kobj.parent = &rtc->dev.kobj; } void rtc_dev_add_device(struct rtc_device *rtc)