public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: scsi_ioctl: use strnlen() in scsi_ioctl_get_pci
@ 2026-04-29  8:15 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-04-29  8:15 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Thorsten Blum, linux-scsi, linux-kernel

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)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-29  8:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  8:15 [PATCH] scsi: scsi_ioctl: use strnlen() in scsi_ioctl_get_pci Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox