Skip to content

Commit 2d3145f

Browse files
committed
early init: fix error handling when opening /dev/console
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 <jsbarnes@google.com> Reported-by: youling 257 <youling257@gmail.com> Fixes: 8243186 ("fs: remove ksys_dup()") Cc: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 58d90a0 commit 2d3145f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎init/main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ void console_on_rootfs(void)
11631163

11641164
/* Open /dev/console in kernelspace, this should never fail */
11651165
file = filp_open("/dev/console", O_RDWR, 0);
1166-
if (!file)
1166+
if (IS_ERR(file))
11671167
goto err_out;
11681168

11691169
/* create stdin/stdout/stderr, this should never fail */

0 commit comments

Comments
 (0)