소스 검색

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>
Dmitry Torokhov 10 년 전
부모
커밋
1e4cd62558
1개의 변경된 파일1개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      drivers/rtc/rtc-dev.c

+ 1 - 0
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);
 	cdev_init(&rtc->char_dev, &rtc_dev_fops);
 	rtc->char_dev.owner = rtc->owner;
 	rtc->char_dev.owner = rtc->owner;
+	rtc->char_dev.kobj.parent = &rtc->dev.kobj;
 }
 }
 
 
 void rtc_dev_add_device(struct rtc_device *rtc)
 void rtc_dev_add_device(struct rtc_device *rtc)