[PATCH] scsi: megaraid_sas: Convert union megasas_sgl to flex-arrays

Kees Cook posted 1 patch 2 years, 9 months ago
drivers/scsi/megaraid/megaraid_sas.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] scsi: megaraid_sas: Convert union megasas_sgl to flex-arrays
Posted by Kees Cook 2 years, 9 months ago
In the ongoing effort to replace all fake flexible arrays with true
flexible arrays, replace the sge32, sge64, and sge_skinny members of
union megasas_sgl with true flexible arrays. No binary differences are
seen after this change; sizes were already being manually calculated
using the member struct sizes directly.

Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: megaraidlinux.pdl@broadcom.com
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/scsi/megaraid/megaraid_sas.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 63bac3684c19..3554f6b07727 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1722,11 +1722,9 @@ struct megasas_sge_skinny {
 } __packed;
 
 union megasas_sgl {
-
-	struct megasas_sge32 sge32[1];
-	struct megasas_sge64 sge64[1];
-	struct megasas_sge_skinny sge_skinny[1];
-
+	DECLARE_FLEX_ARRAY(struct megasas_sge32, sge32);
+	DECLARE_FLEX_ARRAY(struct megasas_sge64, sge64);
+	DECLARE_FLEX_ARRAY(struct megasas_sge_skinny, sge_skinny);
 } __attribute__ ((packed));
 
 struct megasas_header {
-- 
2.34.1
Re: [PATCH] scsi: megaraid_sas: Convert union megasas_sgl to flex-arrays
Posted by Martin K. Petersen 2 years, 8 months ago
On Thu, 11 May 2023 15:10:00 -0700, Kees Cook wrote:

> In the ongoing effort to replace all fake flexible arrays with true
> flexible arrays, replace the sge32, sge64, and sge_skinny members of
> union megasas_sgl with true flexible arrays. No binary differences are
> seen after this change; sizes were already being manually calculated
> using the member struct sizes directly.
> 
> 
> [...]

Applied to 6.5/scsi-queue, thanks!

[1/1] scsi: megaraid_sas: Convert union megasas_sgl to flex-arrays
      https://git.kernel.org/mkp/scsi/c/aa67380056a4

-- 
Martin K. Petersen	Oracle Linux Engineering
Re: [PATCH] scsi: megaraid_sas: Convert union megasas_sgl to flex-arrays
Posted by Martin K. Petersen 2 years, 9 months ago
Kees,

> In the ongoing effort to replace all fake flexible arrays with true
> flexible arrays, replace the sge32, sge64, and sge_skinny members of
> union megasas_sgl with true flexible arrays. No binary differences are
> seen after this change; sizes were already being manually calculated
> using the member struct sizes directly.

Applied to 6.5/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering