diff options
author | Justin Tee <justin.tee@broadcom.com> | 2023-01-10 00:33:07 +0100 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2023-01-12 06:03:14 +0100 |
commit | 1f7b5f94f8d0c97f9b6d10e5ba47e15459ff74ff (patch) | |
tree | fb5ab07680de0028bd914e2b0101fb944fd75364 /drivers/scsi/lpfc/lpfc_attr.c | |
parent | scsi: lpfc: Fix space indentation in lpfc_xcvr_data_show() (diff) | |
download | linux-1f7b5f94f8d0c97f9b6d10e5ba47e15459ff74ff.tar.xz linux-1f7b5f94f8d0c97f9b6d10e5ba47e15459ff74ff.zip |
scsi: lpfc: Replace outdated strncpy() with strscpy()
The kernel test robot pointed out non-NULL terminated string possibilities
when using strncpy() in lpfc_xcvr_data_show() routine. Although we
manually set the NULL character after strncpy(), strncpy() usage is
outdated.
Replace all strncpy() usages with the preferred strscpy() API.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 9df90c0ab44d..c95401225057 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -1905,8 +1905,7 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr, goto out_free_rdp; } - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16); len = scnprintf(buf, PAGE_SIZE - len, "VendorName:\t%s\n", chbuf); len += scnprintf(buf + len, PAGE_SIZE - len, @@ -1914,17 +1913,13 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr, (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI], (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 1], (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 2]); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorPN:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16); - chbuf[16] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorSN:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4); - chbuf[4] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4); len += scnprintf(buf + len, PAGE_SIZE - len, "VendorRev:\t%s\n", chbuf); - strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8); - chbuf[8] = 0; + strscpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8); len += scnprintf(buf + len, PAGE_SIZE - len, "DateCode:\t%s\n", chbuf); len += scnprintf(buf + len, PAGE_SIZE - len, "Identifier:\t%xh\n", (uint8_t)rdp_context->page_a0[SSF_IDENTIFIER]); |