Commit 30e99f05 authored by Dan Carpenter's avatar Dan Carpenter Committed by Martin K. Petersen

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.

Link: https://lore.kernel.org/r/20211013083005.GA8592@kili
Fixes: 76a4f7cc ("scsi: mpi3mr: Clean up mpi3mr_print_ioc_info()")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c4da1205
...@@ -3045,7 +3045,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc) ...@@ -3045,7 +3045,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc)
for (i = 0; i < ARRAY_SIZE(mpi3mr_protocols); i++) { for (i = 0; i < ARRAY_SIZE(mpi3mr_protocols); i++) {
if (mrioc->facts.protocol_flags & if (mrioc->facts.protocol_flags &
mpi3mr_protocols[i].protocol) { mpi3mr_protocols[i].protocol) {
bytes_written += snprintf(protocol + bytes_written, bytes_written += scnprintf(protocol + bytes_written,
sizeof(protocol) - bytes_written, "%s%s", sizeof(protocol) - bytes_written, "%s%s",
bytes_written ? "," : "", bytes_written ? "," : "",
mpi3mr_protocols[i].name); mpi3mr_protocols[i].name);
...@@ -3056,7 +3056,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc) ...@@ -3056,7 +3056,7 @@ mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc)
for (i = 0; i < ARRAY_SIZE(mpi3mr_capabilities); i++) { for (i = 0; i < ARRAY_SIZE(mpi3mr_capabilities); i++) {
if (mrioc->facts.protocol_flags & if (mrioc->facts.protocol_flags &
mpi3mr_capabilities[i].capability) { mpi3mr_capabilities[i].capability) {
bytes_written += snprintf(capabilities + bytes_written, bytes_written += scnprintf(capabilities + bytes_written,
sizeof(capabilities) - bytes_written, "%s%s", sizeof(capabilities) - bytes_written, "%s%s",
bytes_written ? "," : "", bytes_written ? "," : "",
mpi3mr_capabilities[i].name); mpi3mr_capabilities[i].name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment