Linux RAID subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "David Laight" <david.laight.linux@gmail.com>
Cc: yukuai@fygo.io, linux-raid@vger.kernel.org
Subject: Re: [PATCH v2 next] drivers/md/md: Use bounded strings ops when setting disk->disk_name
Date: Fri, 26 Jun 2026 08:51:40 +0000	[thread overview]
Message-ID: <20260626085141.3AEBC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626084334.3012-1-david.laight.linux@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Inconsistent coding style for the sizeof operator in newly added code.
--

commit 663613700e83a5bb9c1749d80b4fae68752645fb
Author: David Laight <david.laight.linux@gmail.com>

drivers/md/md: Use bounded strings ops when setting disk->disk_name

This commit replaces unbounded strcpy() and sprintf() with bounded strscpy()
and snprintf() operations when setting the disk_name in md_alloc() to improve
safety.

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index d1465bcd86c81..afbdc52a11270 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6354,11 +6354,11 @@ struct mddev *md_alloc(dev_t dev, char *name)
[ ... ]
>  	if (name)
> -		strcpy(disk->disk_name, name);
> +		strscpy(disk->disk_name, name);
>  	else if (partitioned)
> -		sprintf(disk->disk_name, "md_d%d", unit);
> +		snprintf(disk->disk_name, sizeof(disk->disk_name), "md_d%d", unit);
>  	else
> -		sprintf(disk->disk_name, "md%d", unit);
> +		snprintf(disk->disk_name, sizeof (disk->disk_name), "md%d", unit);

[Severity: Low]
This isn't a bug, but there is an inconsistent coding style for the sizeof
operator here in md_alloc(). The adjacent branch uses sizeof(disk->disk_name)
without a space, while this newly added branch includes a space. The kernel
coding style prefers no space after sizeof.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626084334.3012-1-david.laight.linux@gmail.com?part=1

  reply	other threads:[~2026-06-26  8:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  8:43 [PATCH v2 next] drivers/md/md: Use bounded strings ops when setting disk->disk_name David Laight
2026-06-26  8:51 ` sashiko-bot [this message]
2026-06-26 10:52   ` David Laight

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=20260626085141.3AEBC1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yukuai@fygo.io \
    /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