mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Aayush Kumar <code@aayushk.dev>
Cc: broonie@kernel.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] spi: lm70llp: Use strscpy() instead of strcpy()
Date: Fri, 9 Oct 2026 15:28:32 +0100	[thread overview]
Message-ID: <20261009152832.4dd56def@pumpkin> (raw)
In-Reply-To: <20261009133609.579046-3-code@aayushk.dev>

On Fri,  9 Oct 2026 19:06:06 +0530
Aayush Kumar <code@aayushk.dev> wrote:

> Use a safer function strscpy() instead of strcpy() for copying to
> arrays. Only idiomatic code replacement, and no functional changes.
> 
> Signed-off-by: Aayush Kumar <code@aayushk.dev>
> ---
>  drivers/spi/spi-lm70llp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-lm70llp.c b/drivers/spi/spi-lm70llp.c
> index e61e89b41..bd8028892 100644
> --- a/drivers/spi/spi-lm70llp.c
> +++ b/drivers/spi/spi-lm70llp.c
> @@ -252,7 +252,7 @@ static void spi_lm70llp_attach(struct parport *p)
>  	 * We are binding to the generic drivers/hwmon/lm70.c device
>  	 * driver.
>  	 */
> -	strcpy(pp->info.modalias, "lm70");
> +	strscpy(pp->info.modalias, "lm70", sizeof(pp->info.modalias));

Come on, if you are going to do that use the two argument form.
Or just don't bother at all.
Do the test compiles - if the literal string is too long you'll
get a compile error for strcpy(), but strscpy() truncates and returns
an error.
So strcpy() is arguably better.

David

>  	pp->info.max_speed_hz = 6 * 1000 * 1000;
>  	pp->info.chip_select = 0;
>  	pp->info.mode = SPI_3WIRE | SPI_MODE_0;


  reply	other threads:[~2026-10-09 14:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 13:36 [PATCH 0/5] spi: replace strcpy(), sprintf() and simple_strtoul() with strscpy(), snprintf() and kstrtoul() Aayush Kumar
2026-10-09 13:36 ` [PATCH 1/5] spi: butterfly: Use strscpy() instead of strcpy() Aayush Kumar
2026-10-09 13:36 ` [PATCH 2/5] spi: lm70llp: " Aayush Kumar
2026-10-09 14:28   ` David Laight [this message]
2026-10-09 17:13     ` Aayush Kumar
2026-10-09 13:36 ` [PATCH 3/5] spi: tle62x0: Use kstrtoul() instead of simple_strtoul() Aayush Kumar
2026-10-09 13:36 ` [PATCH 4/5] spi: omap2-mcspi: Use snprintf() instead of sprintf() Aayush Kumar
2026-10-09 13:36 ` [PATCH 5/5] spi: s3c64xx: " Aayush Kumar

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=20261009152832.4dd56def@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=broonie@kernel.org \
    --cc=code@aayushk.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@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®