Skip to contentSkip to conversation

scsi: mpi3mr: use scnprintf() instead of snprintf()

PATCH Applied Dan Carpenter 2 participants 3 messages Oct 13, 2021 – Oct 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: mpi3mr: use scnprintf() instead of snprintf()

I intended to move from snprintf() to scnprintf() in the previous patch but I messed up and did not do that. The result of my bug is that it this function could trigger a WARN() if the buffer is too large.

Fixes 76a4f7cc5973 ("scsi: mpi3mr: Clean up mpi3mr_print_ioc_info()")
---
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +2 -2
index e34417a2429a..aa5d877df6f8 100644
@@ -3045,7 +3045,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc)
 	for (i = 0; i < ARRAY_SIZE(mpi3mr_protocols); i++) {
 		if (mrioc->facts.protocol_flags &
 		    mpi3mr_protocols[i].protocol) {
-			bytes_written += snprintf(protocol + bytes_written,
+			bytes_written += scnprintf(protocol + bytes_written,
 				    sizeof(protocol) - bytes_written, "%s%s",
 				    bytes_written ? "," : "",
 				    mpi3mr_protocols[i].name);
@@ -3056,7 +3056,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc)
 	for (i = 0; i < ARRAY_SIZE(mpi3mr_capabilities); i++) {
 		if (mrioc->facts.protocol_flags &
 		    mpi3mr_capabilities[i].capability) {
-			bytes_written += snprintf(capabilities + bytes_written,
+			bytes_written += scnprintf(capabilities + bytes_written,
 				    sizeof(capabilities) - bytes_written, "%s%s",
 				    bytes_written ? "," : "",
 				    mpi3mr_capabilities[i].name);
Signature · 1 line
2.20.1
#1 lore raw

Dan,

Quoted 4 lines

I intended to move from snprintf() to scnprintf() in the previous patch but I messed up and did not do that. The result of my bug is that it this function could trigger a WARN() if the buffer is too large.

Applied to 5.16/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

I intended to move from snprintf() to scnprintf() in the previous patch but I messed up and did not do that. The result of my bug is that it this function could trigger a WARN() if the buffer is too large.

Applied to 5.16/scsi-queue, thanks!

[1/1] scsi: mpi3mr: use scnprintf() instead of snprintf()

      https://git.kernel.org/mkp/scsi/c/30e99f05f8b1
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering