Commit 7c32f3a2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix file leak in fadvise()

It can miss an fput() if passed the fd of a file which has no ->mapping.
parent ecd0bd4a
......@@ -33,8 +33,10 @@ long sys_fadvise64(int fd, loff_t offset, size_t len, int advice)
inode = file->f_dentry->d_inode;
mapping = inode->i_mapping;
if (!mapping)
return -EINVAL;
if (!mapping) {
ret = -EINVAL;
goto out;
}
bdi = mapping->backing_dev_info;
......@@ -69,6 +71,7 @@ long sys_fadvise64(int fd, loff_t offset, size_t len, int advice)
default:
ret = -EINVAL;
}
out:
fput(file);
return ret;
}
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