Re: [PATCH 25/28] EDAC/thunderx: Replace strlcat() with seq_buf

From: Kees Cook

Date: Tue Sep 15 2026 - 16:02:37 EST


On Tue, Sep 15, 2026 at 08:18:42AM +0000, Bill Wendling wrote:
> index e7c335ca0c36..4e3781815b6d 100644
> --- a/drivers/edac/thunderx_edac.c
> +++ b/drivers/edac/thunderx_edac.c
> @@ -20,6 +20,7 @@
> #include <linux/atomic.h>
> #include <linux/bitfield.h>
> #include <linux/circ_buf.h>
> +#include <linux/seq_buf.h>
>
> #include <asm/page.h>
>
> @@ -47,12 +48,17 @@ static void decode_register(char *str, size_t size,
> {
> int ret = 0;
>
> + if (size > 0)
> + str[0] = '\0';
> +
> while (descr->type && descr->mask && descr->descr) {
> if (reg & descr->mask) {
> ret = snprintf(str, size, "\n\t%s, %s",
> descr->type == ERR_CORRECTED ?
> "Corrected" : "Uncorrected",
> descr->descr);
> + if (ret < 0 || ret >= size)
> + break;
> str += ret;
> size -= ret;
> }

Seems like seq_buf would be better her? But yes, at the very least, this
needs to be scnprintf, not snprintf (or add the checks as you have
here).

The rest of the seq_buf conversions look right.

--
Kees Cook