[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-hardening
Subject: [PATCH v2 2/2] media: staging/intel-ipu3: css: Use the struct_size() helper
From: "Gustavo A. R. Silva" <gustavoars () kernel ! org>
Date: 2021-07-30 12:09:44
Message-ID: 4da2e05ea7b19a729859d2c34aa2b17a970422e8.1627646101.git.gustavoars () kernel ! org
[Download RAW message or body]
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 --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",
--
2.27.0
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic