Skip to content

Commit

Permalink
early init: fix error handling when opening /dev/console
Browse files Browse the repository at this point in the history
The comment says "this should never fail", but it definitely can fail
when you have odd initial boot filesystems, or kernel configurations.

So get the error handling right: filp_open() returns an error pointer.

Reported-by: Jesse Barnes <[email protected]>
Reported-by: youling 257 <[email protected]>
Fixes: 8243186 ("fs: remove ksys_dup()")
Cc: Dominik Brodowski <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Dec 17, 2019
1 parent 58d90a0 commit 2d3145f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ void console_on_rootfs(void)

/* Open /dev/console in kernelspace, this should never fail */
file = filp_open("/dev/console", O_RDWR, 0);
if (!file)
if (IS_ERR(file))
goto err_out;

/* create stdin/stdout/stderr, this should never fail */
Expand Down

0 comments on commit 2d3145f

Please sign in to comment.