Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: lpfc: Replace one-element array with flexible-array member

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in a couple of structures, and refactor the rest of the code,
accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy() and help us make progress towards globally enabling
-fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/295
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/6c6dcab88524c14c47fd06b9332bd96162656db5.1684358315.git.gustavoars@kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Gustavo A. R. Silva and committed by
Martin K. Petersen
e90644b0 144679df

+6 -4
+4 -2
drivers/scsi/lpfc/lpfc_ct.c
··· 3748 3748 rap->obj[0].entity_id_len = vmid->vmid_len; 3749 3749 memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len); 3750 3750 size = RAPP_IDENT_OFFSET + 3751 - sizeof(struct lpfc_vmid_rapp_ident_list); 3751 + sizeof(struct lpfc_vmid_rapp_ident_list) + 3752 + sizeof(struct entity_id_object); 3752 3753 retry = 1; 3753 3754 break; 3754 3755 ··· 3768 3767 dap->obj[0].entity_id_len = vmid->vmid_len; 3769 3768 memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len); 3770 3769 size = DAPP_IDENT_OFFSET + 3771 - sizeof(struct lpfc_vmid_dapp_ident_list); 3770 + sizeof(struct lpfc_vmid_dapp_ident_list) + 3771 + sizeof(struct entity_id_object); 3772 3772 write_lock(&vport->vmid_lock); 3773 3773 vmid->flag &= ~LPFC_VMID_REGISTERED; 3774 3774 write_unlock(&vport->vmid_lock);
+2 -2
drivers/scsi/lpfc/lpfc_hw.h
··· 1415 1415 1416 1416 struct lpfc_vmid_rapp_ident_list { 1417 1417 uint32_t no_of_objects; 1418 - struct entity_id_object obj[1]; 1418 + struct entity_id_object obj[]; 1419 1419 }; 1420 1420 1421 1421 struct lpfc_vmid_dapp_ident_list { 1422 1422 uint32_t no_of_objects; 1423 - struct entity_id_object obj[1]; 1423 + struct entity_id_object obj[]; 1424 1424 }; 1425 1425 1426 1426 #define GALLAPPIA_ID_LAST 0x80