Skip to content

Commit

Permalink
drbd: add module_put() on error path in drbd_proc_open()
Browse files Browse the repository at this point in the history
If single_open() fails in drbd_proc_open(), module refcount is left incremented.
The patch adds module_put() on the error path.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Alexey Khoroshilov authored and Jens Axboe committed Mar 28, 2013
1 parent 607f25e commit 193d015
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/block/drbd/drbd_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ static int drbd_seq_show(struct seq_file *seq, void *v)

static int drbd_proc_open(struct inode *inode, struct file *file)
{
if (try_module_get(THIS_MODULE))
return single_open(file, drbd_seq_show, PDE(inode)->data);
int err;

if (try_module_get(THIS_MODULE)) {
err = single_open(file, drbd_seq_show, PDE(inode)->data);
if (err)
module_put(THIS_MODULE);
return err;
}
return -ENODEV;
}

Expand Down

0 comments on commit 193d015

Please sign in to comment.