From: Linus Torvalds Date: Tue, 17 Dec 2019 21:10:11 +0000 (-0800) Subject: early init: fix error handling when opening /dev/console X-Git-Tag: microblaze-v5.7-rc1~398 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=2d3145f8d280;p=linux-2.6-microblaze.git 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 Reported-by: youling 257 Fixes: 8243186f0cc7 ("fs: remove ksys_dup()") Cc: Dominik Brodowski Signed-off-by: Linus Torvalds --- diff --git a/init/main.c b/init/main.c index ec3a1463ac69..1ecfd43ed464 100644 --- a/init/main.c +++ b/init/main.c @@ -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 */