From: Thorsten Blum <thorsten.blum@linux.dev>
To: Chris Zankel <chris@zankel.net>, Max Filippov <jcmvbkbc@gmail.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>, linux-kernel@vger.kernel.org
Subject: [PATCH] tty: xtensa/iss: use strnlen to improve iss_console_write
Date: Thu, 30 Apr 2026 11:02:54 +0200 [thread overview]
Message-ID: <20260430090253.237654-3-thorsten.blum@linux.dev> (raw)
Use strnlen() to limit scanning 's' to 'count' bytes. Use the length of
's' to decide if simc_write() should be called instead of dereferencing
it first and then calling strlen().
With strnlen(), iss_console_write() is further hardened against callers
where 's' is not NUL-terminated.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/xtensa/platforms/iss/console.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 8b95221375a8..8e54625cb2ba 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -166,8 +166,9 @@ late_initcall(rs_init);
static void iss_console_write(struct console *co, const char *s, unsigned count)
{
- if (s && *s != 0)
- simc_write(1, s, min(count, strlen(s)));
+ count = s ? strnlen(s, count) : 0;
+ if (count)
+ simc_write(1, s, count);
}
static struct tty_driver* iss_console_device(struct console *c, int *index)
next reply other threads:[~2026-04-30 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 9:02 Thorsten Blum [this message]
2026-04-30 9:45 ` Max Filippov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260430090253.237654-3-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=chris@zankel.net \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®