* [PATCH v3] mpi3mr: Fix W=1 compilation warnings
@ 2021-07-07 8:17 Sreekanth Reddy
2021-07-13 1:57 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Sreekanth Reddy @ 2021-07-07 8:17 UTC (permalink / raw)
To: linux-scsi, martin.petersen
Cc: jejb, mpi3mr-linuxdrv.pdl, kashyap.desai, sathya.prakash,
Sreekanth Reddy, kernel test robot
[-- Attachment #1: Type: text/plain, Size: 2199 bytes --]
Fix for below W=1 compilation warning,
'strncpy' output may be truncated copying 16 bytes
from a string of length 64
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
v3:
- strscpy() itself will add NULL terminator,
so no need to add NULL terminator again.
- Also replace strncpy() with strscpy() in subsequent lines.
v2:
Replace memcpy() with strscpy()
drivers/scsi/mpi3mr/mpi3mr_fw.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 9eceafca59bc..2dba2b0af166 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -2607,14 +2607,13 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc)
goto out;
}
drv_info->information_length = cpu_to_le32(data_len);
- strncpy(drv_info->driver_signature, "Broadcom", sizeof(drv_info->driver_signature));
- strncpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name));
- drv_info->os_name[sizeof(drv_info->os_name) - 1] = 0;
- strncpy(drv_info->os_version, utsname()->release, sizeof(drv_info->os_version));
- drv_info->os_version[sizeof(drv_info->os_version) - 1] = 0;
- strncpy(drv_info->driver_name, MPI3MR_DRIVER_NAME, sizeof(drv_info->driver_name));
- strncpy(drv_info->driver_version, MPI3MR_DRIVER_VERSION, sizeof(drv_info->driver_version));
- strncpy(drv_info->driver_release_date, MPI3MR_DRIVER_RELDATE, sizeof(drv_info->driver_release_date));
+ strscpy(drv_info->driver_signature, "Broadcom", sizeof(drv_info->driver_signature));
+ strscpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name));
+ strscpy(drv_info->os_version, utsname()->release, sizeof(drv_info->os_version));
+ strscpy(drv_info->driver_name, MPI3MR_DRIVER_NAME, sizeof(drv_info->driver_name));
+ strscpy(drv_info->driver_version, MPI3MR_DRIVER_VERSION, sizeof(drv_info->driver_version));
+ strscpy(drv_info->driver_release_date, MPI3MR_DRIVER_RELDATE,
+ sizeof(drv_info->driver_release_date));
drv_info->driver_capabilities = 0;
memcpy((u8 *)&mrioc->driver_info, (u8 *)drv_info,
sizeof(mrioc->driver_info));
--
2.27.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] mpi3mr: Fix W=1 compilation warnings
2021-07-07 8:17 [PATCH v3] mpi3mr: Fix W=1 compilation warnings Sreekanth Reddy
@ 2021-07-13 1:57 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-07-13 1:57 UTC (permalink / raw)
To: Sreekanth Reddy
Cc: linux-scsi, martin.petersen, jejb, mpi3mr-linuxdrv.pdl,
kashyap.desai, sathya.prakash, kernel test robot
Sreekanth,
> Fix for below W=1 compilation warning,
> 'strncpy' output may be truncated copying 16 bytes
> from a string of length 64
Applied to 5.14/scsi-fixes, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-13 1:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 8:17 [PATCH v3] mpi3mr: Fix W=1 compilation warnings Sreekanth Reddy
2021-07-13 1:57 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).