scsi: lpfc: Use memcpy() for BIOS version
[ Upstream commit ae82eaf4aeea060bb736c3e20c0568b67c701d7d ] The strlcat() with FORTIFY support is triggering a panic because it thinks the target buffer will overflow although the correct target buffer size is passed in. Anyway, instead of memset() with 0 followed by a strlcat(), just use memcpy() and ensure that the resulting buffer is NULL terminated. BIOSVersion is only used for the lpfc_printf_log() which expects a properly terminated string. Signed-off-by: Daniel Wagner <wagi@kernel.org> Link: https://lore.kernel.org/r/20250409-fix-lpfc-bios-str-v1-1-05dac9e51e13@kernel.org Reviewed-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
79dc5e78d1
commit
34c0a67055
@@ -6014,9 +6014,9 @@ lpfc_sli4_get_ctl_attr(struct lpfc_hba *phba)
|
|||||||
phba->sli4_hba.flash_id = bf_get(lpfc_cntl_attr_flash_id, cntl_attr);
|
phba->sli4_hba.flash_id = bf_get(lpfc_cntl_attr_flash_id, cntl_attr);
|
||||||
phba->sli4_hba.asic_rev = bf_get(lpfc_cntl_attr_asic_rev, cntl_attr);
|
phba->sli4_hba.asic_rev = bf_get(lpfc_cntl_attr_asic_rev, cntl_attr);
|
||||||
|
|
||||||
memset(phba->BIOSVersion, 0, sizeof(phba->BIOSVersion));
|
memcpy(phba->BIOSVersion, cntl_attr->bios_ver_str,
|
||||||
strlcat(phba->BIOSVersion, (char *)cntl_attr->bios_ver_str,
|
|
||||||
sizeof(phba->BIOSVersion));
|
sizeof(phba->BIOSVersion));
|
||||||
|
phba->BIOSVersion[sizeof(phba->BIOSVersion) - 1] = '\0';
|
||||||
|
|
||||||
lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
|
lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
|
||||||
"3086 lnk_type:%d, lnk_numb:%d, bios_ver:%s, "
|
"3086 lnk_type:%d, lnk_numb:%d, bios_ver:%s, "
|
||||||
|
Reference in New Issue
Block a user