From e7f08f35ef04876d4981a4c9283efea2ba78ec3f Mon Sep 17 00:00:00 2001 From: kunpHust Date: Tue, 9 May 2023 17:52:07 +0000 Subject: [PATCH] xtensa: fix a nullptr bug in iss_console_write() xtensa inclusion category: bugfix bugzilla: NA CVE: NA Reference: N/A ---------------------------------------------------------------- pointer 's' could be a nullptr, so it should be checked first before being sent to function 'strlen' . Signed-off-by: kunpHust --- arch/xtensa/platforms/iss/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index af81a62faba6..3cda02f0a8d6 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -224,10 +224,12 @@ late_initcall(rs_init); static void iss_console_write(struct console *co, const char *s, unsigned count) { - int len = strlen(s); + int len; - if (s != 0 && *s != 0) + if (s != 0 && *s != 0) { + len = strlen(s); simc_write(1, s, count < len ? count : len); + } } static struct tty_driver* iss_console_device(struct console *c, int *index) -- Gitee