Skip to content

Commit

Permalink
Call sysctl_head_finish on error
Browse files Browse the repository at this point in the history
This error path returned directly instead of calling sysctl_head_finish().

Fixes: ef9d965 ("sysctl: reject gigantic reads/write to sysctl files")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Matthew Wilcox (Oracle) authored and Al Viro committed Jul 3, 2020
1 parent b3a9e3b commit d4d80e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,9 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
goto out;

/* don't even try if the size is too large */
if (count > KMALLOC_MAX_SIZE)
return -ENOMEM;
error = -ENOMEM;
if (count >= KMALLOC_MAX_SIZE)
goto out;

if (write) {
kbuf = memdup_user_nul(ubuf, count);
Expand All @@ -576,7 +577,6 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
goto out;
}
} else {
error = -ENOMEM;
kbuf = kzalloc(count, GFP_KERNEL);
if (!kbuf)
goto out;
Expand Down

0 comments on commit d4d80e6

Please sign in to comment.