Skip to contentSkip to conversation

scsi: qla2xxx: avoid stack frame size warning in qla_dfs

PATCH Applied Arnd Bergmann 2 participants 3 messages Jun 20, 2025 – Jul 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: qla2xxx: avoid stack frame size warning in qla_dfs

From: Arnd Bergmann <[email protected]>

The qla2x00_dfs_tgt_port_database_show() function constructs a fake fc_port_t object on the stack, which depending on the configuration is large enough to exceed the stack size warning limit:

drivers/scsi/qla2xxx/qla_dfs.c:176:1: error: stack frame size (1392) exceeds limit (1280) in 'qla2x00_dfs_tgt_port_database_show' [-Werror,-Wframe-larger-than]

Rework this function to no longer need the structure but instead call a custom helper function that just prints the data directly from the port_database_24xx structure.

---
v2: address review comments from ALOK TIWARI

---
 drivers/scsi/qla2xxx/qla_dfs.c | 20 +++++---------
 drivers/scsi/qla2xxx/qla_gbl.h |  1 +
 drivers/scsi/qla2xxx/qla_mbx.c | 48 ++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 14 deletions(-)
drivers/scsi/qla2xxx/qla_dfs.c +6 -14
index 08273520c777..43970caca7b3 100644
@@ -179,10 +179,9 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
 	struct qla_hw_data *ha = vha->hw;
 	struct gid_list_info *gid_list;
 	dma_addr_t gid_list_dma;
-	fc_port_t fc_port;
 	char *id_iter;
 	int rc, i;
-	uint16_t entries, loop_id;
+	uint16_t entries;
 
 	seq_printf(s, "%s\n", vha->host_str);
 	gid_list = dma_alloc_coherent(&ha->pdev->dev,
@@ -205,18 +204,11 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
 	seq_puts(s, "Port Name	Port ID		Loop ID\n");
 
 	for (i = 0; i < entries; i++) {
-		struct gid_list_info *gid =
-			(struct gid_list_info *)id_iter;
-		loop_id = le16_to_cpu(gid->loop_id);
-		memset(&fc_port, 0, sizeof(fc_port_t));
-
-		fc_port.loop_id = loop_id;
-
-		rc = qla24xx_gpdb_wait(vha, &fc_port, 0);
-		seq_printf(s, "%8phC  %02x%02x%02x  %d\n",
-			   fc_port.port_name, fc_port.d_id.b.domain,
-			   fc_port.d_id.b.area, fc_port.d_id.b.al_pa,
-			   fc_port.loop_id);
+		struct gid_list_info *gid = (struct gid_list_info *)id_iter;
+
+		rc = qla24xx_print_fc_port_id(vha, s, le16_to_cpu(gid->loop_id));
+		if (rc != QLA_SUCCESS)
+			break;
 		id_iter += ha->gid_list_info_size;
 	}
 out_free_id_list:
drivers/scsi/qla2xxx/qla_gbl.h +1 -0
index 03e50e8fc08d..145defc420f2 100644
@@ -557,6 +557,7 @@ qla26xx_dport_diagnostics_v2(scsi_qla_host_t *,
 
 int qla24xx_send_mb_cmd(struct scsi_qla_host *, mbx_cmd_t *);
 int qla24xx_gpdb_wait(struct scsi_qla_host *, fc_port_t *, u8);
+int qla24xx_print_fc_port_id(struct scsi_qla_host *, struct seq_file *, u16);
 int qla24xx_gidlist_wait(struct scsi_qla_host *, void *, dma_addr_t,
     uint16_t *);
 int __qla24xx_parse_gpdb(struct scsi_qla_host *, fc_port_t *,
drivers/scsi/qla2xxx/qla_mbx.c +48 -0

54 lines not on this page · raw message

Signature · 1 line
2.39.5
#1 lore raw

Arnd,

Quoted 3 lines

The qla2x00_dfs_tgt_port_database_show() function constructs a fake fc_port_t object on the stack, which depending on the configuration is large enough to exceed the stack size warning limit:

Applied to 6.17/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#2 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

The qla2x00_dfs_tgt_port_database_show() function constructs a fake fc_port_t object on the stack, which depending on the configuration is large enough to exceed the stack size warning limit:

drivers/scsi/qla2xxx/qla_dfs.c:176:1: error: stack frame size (1392) exceeds limit (1280) in 'qla2x00_dfs_tgt_port_database_show' [-Werror,-Wframe-larger-than]

Rework this function to no longer need the structure but instead call a custom helper function that just prints the data directly from the port_database_24xx structure.

[...]

Applied to 6.17/scsi-queue, thanks!

[1/1] scsi: qla2xxx: avoid stack frame size warning in qla_dfs

      https://git.kernel.org/mkp/scsi/c/6243146bb019
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering