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

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 <dmitry.torokhov@gmail.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Dmitry Torokhov and committed by
Alexandre Belloni
1e4cd625 c3b399a4

+1
+1
drivers/rtc/rtc-dev.c
··· 477 477 478 478 cdev_init(&rtc->char_dev, &rtc_dev_fops); 479 479 rtc->char_dev.owner = rtc->owner; 480 + rtc->char_dev.kobj.parent = &rtc->dev.kobj; 480 481 } 481 482 482 483 void rtc_dev_add_device(struct rtc_device *rtc)