Skip to content

Commit

Permalink
printk: fix invalid-free on devkmsg_write()
Browse files Browse the repository at this point in the history
Now buf is allocated on stack and thus doesn't need to be freed.
This leftover would cause undefined behaviour.

Fixes: 9ec4ab41a8b5c ("printk: use buffer from the stack space")

Signed-off-by: xNombre <[email protected]>
Signed-off-by: Park Ju Hyung <[email protected]>
Signed-off-by: celtare21 <[email protected]>
Signed-off-by: engstk <[email protected]>
  • Loading branch information
xNombre authored and engstk committed Dec 9, 2020
1 parent 6db4df4 commit fcb0268
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,8 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
}

buf[len] = '\0';
if (!copy_from_iter_full(buf, len, from)) {
kfree(buf);
if (!copy_from_iter_full(buf, len, from))
return -EFAULT;
}

/*
* Extract and skip the syslog prefix <[0-9]*>. Coming from userspace
Expand Down

0 comments on commit fcb0268

Please sign in to comment.