Details
[Home]
Issue of the Implementation # L0026
Brief
drivers/rtc/rtc-proc.c: have no module_put after module get on error path
Detailed Description
In file drivers/rtc/rtc-proc.c function seq_open() can return -ENOMEM.
86 if (!try_module_get(THIS_MODULE)) 87 return -ENODEV; 88 89 return single_open(file, rtc_proc_show, rtc);In this case before exiting (line 89) from rtc_proc_open the module_put(THIS_MODULE) must be called.
Possible solutions
drivers/rtc/rtc-proc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff -puN drivers/rtc/rtc-proc.c~drivers-rtc-add-module_put-on-error-path-in-rtc_proc_open drivers/rtc/rtc-proc.c --- a/drivers/rtc/rtc-proc.c~drivers-rtc-add-module_put-on-error-path-in-rtc_proc_open +++ a/drivers/rtc/rtc-proc.c @@ -81,12 +81,16 @@ static int rtc_proc_show(struct seq_file static int rtc_proc_open(struct inode *inode, struct file *file) { + int ret; struct rtc_device *rtc = PDE(inode)->data; if (!try_module_get(THIS_MODULE)) return -ENODEV; - return single_open(file, rtc_proc_show, rtc); + ret = single_open(file, rtc_proc_show, rtc); + if (ret) + module_put(THIS_MODULE); + return ret; }
Component
linux-kernel 2.6.37
Accepted
https://lkml.org/lkml/2011/1/28/103
commit
Status
Fixed in kernel 2.6.38-rc5
[Home]
»