Skip to content

Commit

Permalink
scsi: smartpqi: Replace one-element arrays with flexible-array members
Browse files Browse the repository at this point in the history
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().

This results in no differences in binary output.

Link: KSPP#79
Link: KSPP#204
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZJNdKDkuRbFZpASS@work
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
GustavoARSilva authored and martinkpetersen committed Jun 22, 2023
1 parent 4b2e287 commit 6f0a92f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/smartpqi/smartpqi.h
Expand Up @@ -982,12 +982,12 @@ struct report_phys_lun_16byte_wwid {

struct report_phys_lun_8byte_wwid_list {
struct report_lun_header header;
struct report_phys_lun_8byte_wwid lun_entries[1];
struct report_phys_lun_8byte_wwid lun_entries[];
};

struct report_phys_lun_16byte_wwid_list {
struct report_lun_header header;
struct report_phys_lun_16byte_wwid lun_entries[1];
struct report_phys_lun_16byte_wwid lun_entries[];
};

struct raid_map_disk_data {
Expand Down
5 changes: 2 additions & 3 deletions drivers/scsi/smartpqi/smartpqi_init.c
Expand Up @@ -1203,7 +1203,6 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
unsigned int i;
u8 rpl_response_format;
u32 num_physicals;
size_t rpl_16byte_wwid_list_length;
void *rpl_list;
struct report_lun_header *rpl_header;
struct report_phys_lun_8byte_wwid_list *rpl_8byte_wwid_list;
Expand Down Expand Up @@ -1232,9 +1231,9 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b

rpl_8byte_wwid_list = rpl_list;
num_physicals = get_unaligned_be32(&rpl_8byte_wwid_list->header.list_length) / sizeof(rpl_8byte_wwid_list->lun_entries[0]);
rpl_16byte_wwid_list_length = sizeof(struct report_lun_header) + (num_physicals * sizeof(struct report_phys_lun_16byte_wwid));

rpl_16byte_wwid_list = kmalloc(rpl_16byte_wwid_list_length, GFP_KERNEL);
rpl_16byte_wwid_list = kmalloc(struct_size(rpl_16byte_wwid_list, lun_entries,
num_physicals), GFP_KERNEL);
if (!rpl_16byte_wwid_list)
return -ENOMEM;

Expand Down

0 comments on commit 6f0a92f

Please sign in to comment.