From: Thorsten Blum <thorsten.blum@linux.dev>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: scsi_ioctl: use strnlen() in scsi_ioctl_get_pci
Date: Wed, 29 Apr 2026 10:15:51 +0200 [thread overview]
Message-ID: <20260429081550.56279-2-thorsten.blum@linux.dev> (raw)
Use strnlen() to limit 'name' string scanning to 20 characters.
Reformat the code and use tabs instead of spaces while at it.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/scsi/scsi_ioctl.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 0ddc95bafc71..d98c2f19b1e9 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -176,10 +176,11 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
name = dev_name(dev);
- /* compatibility with old ioctl which only returned
- * 20 characters */
- return copy_to_user(arg, name, min(strlen(name), (size_t)20))
- ? -EFAULT: 0;
+ /* compatibility with old ioctl which only returned 20 characters */
+ if (copy_to_user(arg, name, strnlen(name, 20)))
+ return -EFAULT;
+
+ return 0;
}
static int sg_get_version(int __user *p)
reply other threads:[~2026-04-29 8:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260429081550.56279-2-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.