scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
Subsystems (2)
PATCH 1/1 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.
--- drivers/scsi/lpfc/lpfc_sli.c | 3 +-- drivers/scsi/lpfc/lpfc_sli4.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +1 -2
@@ -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;
drivers/scsi/lpfc/lpfc_sli4.h +2 -1
@@ -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 {
Signature · 1 line
2.54.0
Regards,
Justin
Martin K. Petersen
AppliedRosen,
Quoted 3 lines
The
q_pgspointer was assigned to point at the trailing memory allocated past the struct. Convert it to a proper C99 flexible array member and usestruct_size()for the allocation.
Applied to 7.2/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 5 lines · Rosen Penev
The
q_pgspointer was assigned to point at the trailing memory allocated past the struct. Convert it to a proper C99 flexible array member and usestruct_size()for the allocation.
Applied to 7.2/scsi-queue, thanks!
[1/1] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
https://git.kernel.org/mkp/scsi/c/056fca1f276f
Signature · 1 line
Martin K. Petersen