Skip to content

Commit

Permalink
rtc: fix module reference count in rtc-proc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Geliang Tang authored and Alexandre Belloni committed Jan 11, 2016
1 parent fbbf53f commit b01079b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/rtc/rtc-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,21 @@ static int rtc_proc_open(struct inode *inode, struct file *file)
int ret;
struct rtc_device *rtc = PDE_DATA(inode);

if (!try_module_get(THIS_MODULE))
if (!try_module_get(rtc->owner))
return -ENODEV;

ret = single_open(file, rtc_proc_show, rtc);
if (ret)
module_put(THIS_MODULE);
module_put(rtc->owner);
return ret;
}

static int rtc_proc_release(struct inode *inode, struct file *file)
{
int res = single_release(inode, file);
module_put(THIS_MODULE);
struct rtc_device *rtc = PDE_DATA(inode);

module_put(rtc->owner);
return res;
}

Expand Down

0 comments on commit b01079b

Please sign in to comment.