Skip to content

Commit 512a365

Browse files
GustavoARSilvamartinkpetersen
authored andcommitted
scsi: qla2xxx: Replace one-element array with DECLARE_FLEX_ARRAY() helper
One-element arrays as fake flex arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace one-element array declaration in struct ct_sns_gpnft_rsp, which is ultimately being used inside a union: drivers/scsi/qla2xxx/qla_def.h: 3240 struct ct_sns_gpnft_pkt { 3241 union { 3242 struct ct_sns_req req; 3243 struct ct_sns_gpnft_rsp rsp; 3244 } p; 3245 }; Refactor the rest of the code, accordingly. This issue was found with the help of Coccinelle. Link: KSPP#245 Link: KSPP#193 Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/ZH+/rZ1R1cBjIxjS@work Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 8cd6d0a commit 512a365

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,12 +3174,12 @@ struct ct_sns_gpnft_rsp {
31743174
uint8_t vendor_unique;
31753175
};
31763176
/* Assume the largest number of targets for the union */
3177-
struct ct_sns_gpn_ft_data {
3177+
DECLARE_FLEX_ARRAY(struct ct_sns_gpn_ft_data {
31783178
u8 control_byte;
31793179
u8 port_id[3];
31803180
u32 reserved;
31813181
u8 port_name[8];
3182-
} entries[1];
3182+
}, entries);
31833183
};
31843184

31853185
/* CT command response */

drivers/scsi/qla2xxx/qla_gs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,8 +3776,8 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
37763776
sp->u.iocb_cmd.u.ctarg.req_size = GPN_FT_REQ_SIZE;
37773777

37783778
rspsz = sizeof(struct ct_sns_gpnft_rsp) +
3779-
((vha->hw->max_fibre_devices - 1) *
3780-
sizeof(struct ct_sns_gpn_ft_data));
3779+
vha->hw->max_fibre_devices *
3780+
sizeof(struct ct_sns_gpn_ft_data);
37813781

37823782
sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
37833783
rspsz,

0 commit comments

Comments
 (0)