Skip to content

Commit 6f0a92f

Browse files
GustavoARSilvamartinkpetersen
authored andcommitted
scsi: smartpqi: Replace one-element arrays with flexible-array members
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>
1 parent 4b2e287 commit 6f0a92f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

drivers/scsi/smartpqi/smartpqi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,12 @@ struct report_phys_lun_16byte_wwid {
982982

983983
struct report_phys_lun_8byte_wwid_list {
984984
struct report_lun_header header;
985-
struct report_phys_lun_8byte_wwid lun_entries[1];
985+
struct report_phys_lun_8byte_wwid lun_entries[];
986986
};
987987

988988
struct report_phys_lun_16byte_wwid_list {
989989
struct report_lun_header header;
990-
struct report_phys_lun_16byte_wwid lun_entries[1];
990+
struct report_phys_lun_16byte_wwid lun_entries[];
991991
};
992992

993993
struct raid_map_disk_data {

drivers/scsi/smartpqi/smartpqi_init.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,6 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
12031203
unsigned int i;
12041204
u8 rpl_response_format;
12051205
u32 num_physicals;
1206-
size_t rpl_16byte_wwid_list_length;
12071206
void *rpl_list;
12081207
struct report_lun_header *rpl_header;
12091208
struct report_phys_lun_8byte_wwid_list *rpl_8byte_wwid_list;
@@ -1232,9 +1231,9 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
12321231

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

1237-
rpl_16byte_wwid_list = kmalloc(rpl_16byte_wwid_list_length, GFP_KERNEL);
1235+
rpl_16byte_wwid_list = kmalloc(struct_size(rpl_16byte_wwid_list, lun_entries,
1236+
num_physicals), GFP_KERNEL);
12381237
if (!rpl_16byte_wwid_list)
12391238
return -ENOMEM;
12401239

0 commit comments

Comments
 (0)