linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init: Fix crash observed if there is no initial console
@ 2019-12-18 23:01 Guenter Roeck
  2019-12-18 23:14 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2019-12-18 23:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Guenter Roeck, Dominik Brodowski, Linus Torvalds

Systems with no initial console crash in f_dupfd(). This happens because
console_on_rootfs() was changed to call filp_open(). Its return value
(a file pointer) is checked against NULL, but returns an ERR_PTR after
errors. This ERR_PTR is then passed as file parameter to f_dupfd(),
which experiences a severe case of indigestion.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Fixes: 8243186f0cc7 ("fs: remove ksys_dup()"),
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 init/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-18 23:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 23:01 [PATCH] init: Fix crash observed if there is no initial console Guenter Roeck
2019-12-18 23:14 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).