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

rtc: fix module reference count in rtc-proc

rtc-proc.c is not built as a module. Thus, rather than dealing with
THIS_MODULE's reference count, we should deal with rtc->owner's
reference count.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Geliang Tang and committed by
Alexandre Belloni
b01079be fbbf53f7

+5 -3
+5 -3
drivers/rtc/rtc-proc.c
··· 112 112 int ret; 113 113 struct rtc_device *rtc = PDE_DATA(inode); 114 114 115 - if (!try_module_get(THIS_MODULE)) 115 + if (!try_module_get(rtc->owner)) 116 116 return -ENODEV; 117 117 118 118 ret = single_open(file, rtc_proc_show, rtc); 119 119 if (ret) 120 - module_put(THIS_MODULE); 120 + module_put(rtc->owner); 121 121 return ret; 122 122 } 123 123 124 124 static int rtc_proc_release(struct inode *inode, struct file *file) 125 125 { 126 126 int res = single_release(inode, file); 127 - module_put(THIS_MODULE); 127 + struct rtc_device *rtc = PDE_DATA(inode); 128 + 129 + module_put(rtc->owner); 128 130 return res; 129 131 } 130 132