Skip to content

Commit d4d80e6

Browse files
Matthew Wilcox (Oracle)Al Viro
authored andcommitted
Call sysctl_head_finish on error
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) <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent b3a9e3b commit d4d80e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/proc/proc_sysctl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,9 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
566566
goto out;
567567

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

572573
if (write) {
573574
kbuf = memdup_user_nul(ubuf, count);
@@ -576,7 +577,6 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf,
576577
goto out;
577578
}
578579
} else {
579-
error = -ENOMEM;
580580
kbuf = kzalloc(count, GFP_KERNEL);
581581
if (!kbuf)
582582
goto out;

0 commit comments

Comments
 (0)