Commit a7823c79 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by J. Bruce Fields

SUNRPC/cache: add module_put() on error path in cache_open()

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: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent ff7c4b36
...@@ -986,8 +986,10 @@ static int cache_open(struct inode *inode, struct file *filp, ...@@ -986,8 +986,10 @@ static int cache_open(struct inode *inode, struct file *filp,
nonseekable_open(inode, filp); nonseekable_open(inode, filp);
if (filp->f_mode & FMODE_READ) { if (filp->f_mode & FMODE_READ) {
rp = kmalloc(sizeof(*rp), GFP_KERNEL); rp = kmalloc(sizeof(*rp), GFP_KERNEL);
if (!rp) if (!rp) {
module_put(cd->owner);
return -ENOMEM; return -ENOMEM;
}
rp->offset = 0; rp->offset = 0;
rp->q.reader = 1; rp->q.reader = 1;
atomic_inc(&cd->readers); atomic_inc(&cd->readers);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment