Skip to content

Commit 29b4a49

Browse files
keesmartinkpetersen
authored andcommitted
scsi: megaraid_sas: struct MR_HOST_DEVICE_LIST: Replace 1-element array with flexible array
Replace the deprecated[1] use of a 1-element array in struct MR_HOST_DEVICE_LIST with a modern flexible array. One binary difference appears in megasas_host_device_list_query(): struct MR_HOST_DEVICE_LIST *ci; ... ci = instance->host_device_list_buf; ... memset(ci, 0, sizeof(*ci)); The memset() clears only the non-flexible array fields. Looking at the rest of the function, this appears to be fine: firmware is using this region to communicate with the kernel, so it likely never made sense to clear the first MR_HOST_DEVICE_LIST_ENTRY. Link: KSPP#79 [1] Signed-off-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20240711155841.work.839-kees@kernel.org Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent ed8ab02 commit 29b4a49

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/scsi/megaraid/megaraid_sas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,12 @@ struct MR_HOST_DEVICE_LIST {
814814
__le32 size;
815815
__le32 count;
816816
__le32 reserved[2];
817-
struct MR_HOST_DEVICE_LIST_ENTRY host_device_list[1];
817+
struct MR_HOST_DEVICE_LIST_ENTRY host_device_list[] __counted_by_le(count);
818818
} __packed;
819819

820820
#define HOST_DEVICE_LIST_SZ (sizeof(struct MR_HOST_DEVICE_LIST) + \
821821
(sizeof(struct MR_HOST_DEVICE_LIST_ENTRY) * \
822-
(MEGASAS_MAX_PD + MAX_LOGICAL_DRIVES_EXT - 1)))
822+
(MEGASAS_MAX_PD + MAX_LOGICAL_DRIVES_EXT)))
823823

824824

825825
/*

0 commit comments

Comments
 (0)