Skip to content

Commit 5cc2da0

Browse files
arndbmartinkpetersen
authored andcommitted
scsi: mpi3mr: Reduce stack usage in mpi3mr_refresh_sas_ports()
Doubling the number of PHYs also doubled the stack usage of this function, exceeding the 32-bit limit of 1024 bytes: drivers/scsi/mpi3mr/mpi3mr_transport.c: In function 'mpi3mr_refresh_sas_ports': drivers/scsi/mpi3mr/mpi3mr_transport.c:1818:1: error: the frame size of 1636 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Since the sas_io_unit_pg0 structure is already allocated dynamically, use the same method here. The size of the allocation can be smaller based on the actual number of phys now, so use this as an upper bound. Fixes: cb5b608 ("scsi: mpi3mr: Increase maximum number of PHYs to 64 from 32") Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Cc: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20240123130754.2011469-1-arnd@kernel.org Tested-by: John Garry <john.g.garry@oracle.com> #build only Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 9ddf190 commit 5cc2da0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/scsi/mpi3mr/mpi3mr_transport.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ mpi3mr_update_mr_sas_port(struct mpi3mr_ioc *mrioc, struct host_port *h_port,
16711671
void
16721672
mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
16731673
{
1674-
struct host_port h_port[64];
1674+
struct host_port *h_port = NULL;
16751675
int i, j, found, host_port_count = 0, port_idx;
16761676
u16 sz, attached_handle, ioc_status;
16771677
struct mpi3_sas_io_unit_page0 *sas_io_unit_pg0 = NULL;
@@ -1685,6 +1685,10 @@ mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
16851685
sas_io_unit_pg0 = kzalloc(sz, GFP_KERNEL);
16861686
if (!sas_io_unit_pg0)
16871687
return;
1688+
h_port = kcalloc(64, sizeof(struct host_port), GFP_KERNEL);
1689+
if (!h_port)
1690+
goto out;
1691+
16881692
if (mpi3mr_cfg_get_sas_io_unit_pg0(mrioc, sas_io_unit_pg0, sz)) {
16891693
ioc_err(mrioc, "failure at %s:%d/%s()!\n",
16901694
__FILE__, __LINE__, __func__);
@@ -1814,6 +1818,7 @@ mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
18141818
}
18151819
}
18161820
out:
1821+
kfree(h_port);
18171822
kfree(sas_io_unit_pg0);
18181823
}
18191824

0 commit comments

Comments
 (0)