mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
@ 2026-05-23  5:02 Rosen Penev
  2026-05-26 20:13 ` Justin Tee
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2026-05-23  5:02 UTC (permalink / raw)
  To: linux-scsi
  Cc: Justin Tee, Paul Ely, James E.J. Bottomley, Martin K. Petersen,
	open list

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>
---
 drivers/scsi/lpfc/lpfc_sli.c  | 3 +--
 drivers/scsi/lpfc/lpfc_sli4.h | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index d38fb374b379..0e56e7034566 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -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;
diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
index 2744786d9c94..e2b95fb50d55 100644
--- a/drivers/scsi/lpfc/lpfc_sli4.h
+++ b/drivers/scsi/lpfc/lpfc_sli4.h
@@ -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 {
-- 
2.54.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
  2026-05-23  5:02 [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array Rosen Penev
@ 2026-05-26 20:13 ` Justin Tee
  2026-06-02  1:47 ` Martin K. Petersen
  2026-06-09  1:39 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Justin Tee @ 2026-05-26 20:13 UTC (permalink / raw)
  To: Rosen Penev, linux-scsi
  Cc: Justin Tee, Paul Ely, James E.J. Bottomley, Martin K. Petersen,
	open list

Reviewed-by: Justin Tee <justin.tee@broadcom.com>

Regards,
Justin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
  2026-05-23  5:02 [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array Rosen Penev
  2026-05-26 20:13 ` Justin Tee
@ 2026-06-02  1:47 ` Martin K. Petersen
  2026-06-09  1:39 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2026-06-02  1:47 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-scsi, Justin Tee, Paul Ely, James E.J. Bottomley,
	Martin K. Petersen, open list


Rosen,

> 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.

Applied to 7.2/scsi-staging, thanks!

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array
  2026-05-23  5:02 [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array Rosen Penev
  2026-05-26 20:13 ` Justin Tee
  2026-06-02  1:47 ` Martin K. Petersen
@ 2026-06-09  1:39 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2026-06-09  1:39 UTC (permalink / raw)
  To: linux-scsi, Rosen Penev
  Cc: Martin K . Petersen, Justin Tee, Paul Ely, James E.J. Bottomley,
	linux-kernel

On Fri, 22 May 2026 22:02:41 -0700, Rosen Penev wrote:

> 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.
> 
> 

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

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-09  1:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-23  5:02 [PATCH] scsi: lpfc: turn lpfc_queue q_pgs into a flexible array Rosen Penev
2026-05-26 20:13 ` Justin Tee
2026-06-02  1:47 ` Martin K. Petersen
2026-06-09  1:39 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome