]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: lpfc: Turn lpfc_queue q_pgs into a flexible array
authorRosen Penev <rosenp@gmail.com>
Sat, 23 May 2026 05:02:41 +0000 (22:02 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 2 Jun 2026 01:46:50 +0000 (21:46 -0400)
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>
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_sli4.h

index d38fb374b379acbd2455b3028e6c04a423e6fcf3..0e56e70345662fce6c2b16b194e39470f13d1591 100644 (file)
@@ -15875,7 +15875,7 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t page_size,
        if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt)
                pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt;
 
-       queue = kzalloc_node(sizeof(*queue) + (sizeof(void *) * pgcnt),
+       queue = kzalloc_node(struct_size(queue, q_pgs, pgcnt),
                             GFP_KERNEL, cpu_to_node(cpu));
        if (!queue)
                return NULL;
@@ -15892,7 +15892,6 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t page_size,
         * resources, the free routine needs to know what was allocated.
         */
        queue->page_count = pgcnt;
-       queue->q_pgs = (void **)&queue[1];
        queue->entry_cnt_per_pg = hw_page_size / entry_size;
        queue->entry_size = entry_size;
        queue->entry_count = entry_count;
index 2744786d9c94f179a72d688963e84295ab8b3331..e2b95fb50d55583abe787583a794b4fc6ec3172c 100644 (file)
@@ -280,9 +280,10 @@ struct lpfc_queue {
        uint64_t isr_timestamp;
        struct lpfc_queue *assoc_qp;
        struct list_head _poll_list;
-       void **q_pgs;   /* array to index entries per page */
 
        enum lpfc_poll_mode poll_mode;
+
+       void *q_pgs[];  /* array to index entries per page */
 };
 
 struct lpfc_sli4_link {