Skip to content

Commit

Permalink
SUNRPC/cache: add module_put() on error path in cache_open()
Browse files Browse the repository at this point in the history
If kmalloc() fails in cache_open(), module cd->owner left locked.
The patch adds module_put(cd->owner) on this path.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Alexey Khoroshilov authored and J. Bruce Fields committed Apr 3, 2013
1 parent ff7c4b3 commit a7823c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/sunrpc/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,10 @@ static int cache_open(struct inode *inode, struct file *filp,
nonseekable_open(inode, filp);
if (filp->f_mode & FMODE_READ) {
rp = kmalloc(sizeof(*rp), GFP_KERNEL);
if (!rp)
if (!rp) {
module_put(cd->owner);
return -ENOMEM;
}
rp->offset = 0;
rp->q.reader = 1;
atomic_inc(&cd->readers);
Expand Down

0 comments on commit a7823c7

Please sign in to comment.