aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/sas.h
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>2022-06-09 11:24:54 +0900
committerMartin K. Petersen <martin.petersen@oracle.com>2022-06-10 13:08:06 -0400
commitc3752f44604f3bc4f3ce6e169fa32d16943ff70b (patch)
treece26ce9bd87dc88c376c6c929a533fc6b18e3795 /include/scsi/sas.h
parentscsi: qla2xxx: Update version to 10.02.07.600-k (diff)
downloadlinux-dev-c3752f44604f3bc4f3ce6e169fa32d16943ff70b.tar.xz
linux-dev-c3752f44604f3bc4f3ce6e169fa32d16943ff70b.zip
scsi: libsas: Introduce struct smp_disc_resp
When compiling with gcc 12, several warnings are thrown by gcc when compiling drivers/scsi/libsas/sas_expander.c, e.g.: In function ‘sas_get_phy_change_count’, inlined from ‘sas_find_bcast_phy.constprop’ at drivers/scsi/libsas/sas_expander.c:1737:9: drivers/scsi/libsas/sas_expander.c:1697:39: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[56]’ [-Warray-bounds] 1697 | *pcc = disc_resp->disc.change_count; | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~ This is due to the use of the struct smp_resp to aggregate all possible response types using a union but allocating a response buffer with a size exactly equal to the size of the response type needed. This leads to access to fields of struct smp_resp from an allocated memory area that is smaller than the size of struct smp_resp. Fix this by defining struct smp_disc_resp for sas discovery operations. Since this structure and the generic struct smp_resp are identical for the little endian and big endian archs, move the definition of these structures at the end of include/scsi/sas.h to avoid repeating their definition. Link: https://lore.kernel.org/r/20220609022456.409087-2-damien.lemoal@opensource.wdc.com Reviewed-by: John Garry <john.garry@huawei.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include/scsi/sas.h')
-rw-r--r--include/scsi/sas.h28
1 files changed, 12 insertions, 16 deletions
diff --git a/include/scsi/sas.h b/include/scsi/sas.h
index acfc69fd72d0..b3ee9bd63277 100644
--- a/include/scsi/sas.h
+++ b/include/scsi/sas.h
@@ -471,18 +471,6 @@ struct report_phy_sata_resp {
__be32 crc;
} __attribute__ ((packed));
-struct smp_resp {
- u8 frame_type;
- u8 function;
- u8 result;
- u8 reserved;
- union {
- struct report_general_resp rg;
- struct discover_resp disc;
- struct report_phy_sata_resp rps;
- };
-} __attribute__ ((packed));
-
#elif defined(__BIG_ENDIAN_BITFIELD)
struct sas_identify_frame {
/* Byte 0 */
@@ -704,6 +692,18 @@ struct report_phy_sata_resp {
__be32 crc;
} __attribute__ ((packed));
+#else
+#error "Bitfield order not defined!"
+#endif
+
+struct smp_disc_resp {
+ u8 frame_type;
+ u8 function;
+ u8 result;
+ u8 reserved;
+ struct discover_resp disc;
+} __attribute__ ((packed));
+
struct smp_resp {
u8 frame_type;
u8 function;
@@ -716,8 +716,4 @@ struct smp_resp {
};
} __attribute__ ((packed));
-#else
-#error "Bitfield order not defined!"
-#endif
-
#endif /* _SAS_H_ */