Commit d4d80e69 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Al Viro

Call sysctl_head_finish on error

This error path returned directly instead of calling sysctl_head_finish().

Fixes: ef9d965b ("sysctl: reject gigantic reads/write to sysctl files")
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b3a9e3b9
...@@ -566,8 +566,9 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf, ...@@ -566,8 +566,9 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
goto out; goto out;
/* don't even try if the size is too large */ /* don't even try if the size is too large */
if (count > KMALLOC_MAX_SIZE) error = -ENOMEM;
return -ENOMEM; if (count >= KMALLOC_MAX_SIZE)
goto out;
if (write) { if (write) {
kbuf = memdup_user_nul(ubuf, count); kbuf = memdup_user_nul(ubuf, count);
...@@ -576,7 +577,6 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf, ...@@ -576,7 +577,6 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
goto out; goto out;
} }
} else { } else {
error = -ENOMEM;
kbuf = kzalloc(count, GFP_KERNEL); kbuf = kzalloc(count, GFP_KERNEL);
if (!kbuf) if (!kbuf)
goto out; goto out;
......
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