Merge patch series "scsi: mpt3sas: Use flexible arrays and do a few cleanups"
authorMartin K. Petersen <martin.petersen@oracle.com>
Wed, 15 Nov 2023 15:04:03 +0000 (10:04 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 15 Nov 2023 15:04:03 +0000 (10:04 -0500)
James Seo <james@equiv.tech> says:

Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") has
resulted in the only arrays that UBSAN_BOUNDS considers unbounded
being trailing arrays declared with [] as the last member of a
struct. Unbounded trailing arrays declared with [1] are common in
mpt3sas, which is causing spurious warnings to appear in some
situations, e.g. when more than one physical disk is connected:

  UBSAN: array-index-out-of-bounds in drivers/scsi/mpt3sas/mpt3sas_scsih.c:6810:36
  index 1 is out of range for type 'MPI2_SAS_IO_UNIT0_PHY_DATA [1]'

which relates to this unbounded array access:

  port_id = sas_iounit_pg0->PhyData[i].Port;

and is just one example of 10 similar warnings currently occurring for
me during boot.

This series converts most trailing arrays declared with [1] in mptsas
into proper C99 flexible array members. Those that are not unbounded
and really are fixed-length arrays of length 1 are left alone.

I didn't find any conversions that required further source edits
besides changing [1] to [], and everything seems to work with my
SAS2008-based add-in card, but please look things over in case I
missed something subtle.

Rounding out the series are some opportunistic cleanups.

The only dependency is that patch 7 ("Use struct_size() for struct
size calculations") depends on patches 3-5.

Link: https://lore.kernel.org/r/20230806170604.16143-1-james@equiv.tech
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

Trivial merge