diff mbox series

[v2,2/2] media: staging/intel-ipu3: css: Use the struct_size() helper

Message ID 4da2e05ea7b19a729859d2c34aa2b17a970422e8.1627646101.git.gustavoars@kernel.org (mailing list archive)
State New, archived
Headers show
Series Fix size comparison bug and use flexible array | expand

Commit Message

Gustavo A. R. Silva July 30, 2021, 12:09 p.m. UTC
Make use of the struct_size() helper instead of an open-coded version.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
Changes in v2:
 - Move the replacement of one-element array with a flexible-array
   member to patch 1 of the series and update changelog text,
   accordingly.

 drivers/staging/media/ipu3/ipu3-css-fw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/media/ipu3/ipu3-css-fw.c b/drivers/staging/media/ipu3/ipu3-css-fw.c
index 630cb5186b48..b9c850fc9fe4 100644
--- a/drivers/staging/media/ipu3/ipu3-css-fw.c
+++ b/drivers/staging/media/ipu3/ipu3-css-fw.c
@@ -127,9 +127,8 @@  int imgu_css_fw_init(struct imgu_css *css)
 	if (css->fw->size <= sizeof(struct imgu_fw_header) ||
 	    css->fwp->file_header.h_size != sizeof(struct imgu_fw_bi_file_h))
 		goto bad_fw;
-	if (sizeof(struct imgu_fw_bi_file_h) +
-	    css->fwp->file_header.binary_nr * sizeof(struct imgu_fw_info) >
-	    css->fw->size)
+	if (struct_size(css->fwp, binary_header,
+			css->fwp->file_header.binary_nr) > css->fw->size)
 		goto bad_fw;
 
 	dev_info(dev, "loaded firmware version %.64s, %u binaries, %zu bytes\n",