mirror_ubuntu-kernels/drivers/scsi/mpt3sas/mpi
James Seo e249a957ce scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] a flexible array
This terminal 1-length variable array can be directly converted into a C99
flexible array member.

As all users of MPI2_CONFIG_PAGE_SASIOUNIT_1 (Mpi2SasIOUnitPage1_t) either
calculate its size without depending on its sizeof() or do not use
PhyData[], no further source changes are required:

 - mpt3sas_config.c:mpt3sas_config_get_sas_iounit_pg1() fetches a
   Mpi2SasIOUnitPage1_t into a caller-provided buffer, and may fetch and
   write PhyData[] into that buffer depending on its sz argument.  Its
   callers:

   - mpt3sas_base.c:_base_assign_fw_reported_qd() passes
     sizeof(Mpi2SasIOUnitPage1_t) as sz, but does not use PhyData[].

   - mpt3sas_base.c:mpt3sas_base_update_missing_delay(),
     mpt3sas_scsih.c:_scsih_sas_host_add(),
     mpt3sas_transport.c:_transport_phy_enable(), and
     mpt3sas_transport.c:_transport_phy_speed() all calculate sz
     independently of sizeof(Mpi2SasIOUnitPage1_t) and allocate a
     suitable buffer before calling mpt3sas_config_get_sas_iounit_pg1()
     and using PhyData[].

 - mpt3sas_config.c:mpt3sas_config_set_sas_iounit_pg1() writes the contents
   of a caller-provided buffer to the adapter, with the size of the write
   depending on its sz argument. Its callers:

   - mpt3sas_base.c:mpt3sas_base_update_missing_delay(),
     mpt3sas_transport.c:_transport_phy_enable(), and
     mpt3sas_transport.c:_transport_phy_speed() have all previously
     called mpt3sas_config_get_sas_iounit_pg1() to obtain a
     Mpi2SasIOUnitPage1_t, and are merely writing back this same
     struct with the same previously calculated sz.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-6-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-11-15 08:52:02 -05:00
..
mpi2_cnfg.h scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] a flexible array 2023-11-15 08:52:02 -05:00
mpi2_image.h scsi: mpt3sas: Use flexible arrays when obviously possible 2023-11-15 08:52:01 -05:00
mpi2_init.h scsi: mpt3sas: Update MPI headers to support Aero controllers 2018-11-06 20:16:01 -05:00
mpi2_ioc.h scsi: mpt3sas: Use flexible arrays when obviously possible 2023-11-15 08:52:01 -05:00
mpi2_pci.h scsi: mpt3sas: Update MPI headers to 2.6.8 spec 2019-08-07 22:46:19 -04:00
mpi2_raid.h scsi: mpt3sas: Update MPI headers to support Aero controllers 2018-11-06 20:16:01 -05:00
mpi2_sas.h scsi: mpt3sas: Update MPI headers to support Aero controllers 2018-11-06 20:16:01 -05:00
mpi2_tool.h scsi: mpt3sas: Update MPI headers to 2.6.8 spec 2019-08-07 22:46:19 -04:00
mpi2_type.h
mpi2.h scsi: mpt3sas: Remove volatile qualifier 2023-08-30 21:39:06 -04:00