提交 24a6f5b8 编写于 作者: A Alexander Strakh 提交者: Linus Torvalds

drivers/rtc/rtc-proc.c: add module_put on error path in rtc_proc_open()

In file drivers/rtc/rtc-proc.c 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.

Found by Linux Device Drivers Verification Project
Signed-off-by: NAlexander Strakh <strakh@ispras.ru>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 6e20fb18
...@@ -81,12 +81,16 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) ...@@ -81,12 +81,16 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
static int rtc_proc_open(struct inode *inode, struct file *file) static int rtc_proc_open(struct inode *inode, struct file *file)
{ {
int ret;
struct rtc_device *rtc = PDE(inode)->data; struct rtc_device *rtc = PDE(inode)->data;
if (!try_module_get(THIS_MODULE)) if (!try_module_get(THIS_MODULE))
return -ENODEV; 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;
} }
static int rtc_proc_release(struct inode *inode, struct file *file) static int rtc_proc_release(struct inode *inode, struct file *file)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册