[PATCH] scsi: proc: use snprintf() for the host name
From: shao.mingyin
Date: Sun Nov 08 2026 - 22:42:26 EST
From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
scsi_proc_host_add() and scsi_proc_host_rm() format host_no into a
10-byte buffer with sprintf(). host_no is an unsigned int, and once
it grows past nine digits the %d output plus the terminator no longer
fits; use snprintf().
Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index fdc355d783da..d1f474c28720 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -230,7 +230,7 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
if (!e)
goto err;
- sprintf(name,"%d", shost->host_no);
+ snprintf(name, sizeof(name), "%d", shost->host_no);
p = proc_create_data(name, S_IRUGO | S_IWUSR, e->proc_dir,
&proc_scsi_ops, shost);
if (!p)
@@ -260,7 +260,7 @@ void scsi_proc_host_rm(struct Scsi_Host *shost)
if (!e)
return;
- sprintf(name,"%d", shost->host_no);
+ snprintf(name, sizeof(name), "%d", shost->host_no);
remove_proc_entry(name, e->proc_dir);
}
/**