Skip to content

Commit 056fca1

Browse files
nehebmartinkpetersen
authored andcommitted
scsi: lpfc: Turn lpfc_queue q_pgs into a flexible array
The q_pgs pointer was assigned to point at the trailing memory allocated past the struct. Convert it to a proper C99 flexible array member and use struct_size() for the allocation. Assisted-by: Claude:Opus-4.7 Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Justin Tee <justin.tee@broadcom.com> Link: https://patch.msgid.link/20260523050241.190239-1-rosenp@gmail.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 06a34d9 commit 056fca1

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15875,7 +15875,7 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t page_size,
1587515875
if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt)
1587615876
pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt;
1587715877

15878-
queue = kzalloc_node(sizeof(*queue) + (sizeof(void *) * pgcnt),
15878+
queue = kzalloc_node(struct_size(queue, q_pgs, pgcnt),
1587915879
GFP_KERNEL, cpu_to_node(cpu));
1588015880
if (!queue)
1588115881
return NULL;
@@ -15892,7 +15892,6 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t page_size,
1589215892
* resources, the free routine needs to know what was allocated.
1589315893
*/
1589415894
queue->page_count = pgcnt;
15895-
queue->q_pgs = (void **)&queue[1];
1589615895
queue->entry_cnt_per_pg = hw_page_size / entry_size;
1589715896
queue->entry_size = entry_size;
1589815897
queue->entry_count = entry_count;

drivers/scsi/lpfc/lpfc_sli4.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ struct lpfc_queue {
280280
uint64_t isr_timestamp;
281281
struct lpfc_queue *assoc_qp;
282282
struct list_head _poll_list;
283-
void **q_pgs; /* array to index entries per page */
284283

285284
enum lpfc_poll_mode poll_mode;
285+
286+
void *q_pgs[]; /* array to index entries per page */
286287
};
287288

288289
struct lpfc_sli4_link {

0 commit comments

Comments
 (0)