Skip to content

Commit 2c2661e

Browse files
yasinleexgregkh
authored andcommitted
iio: proximity: hx9023s: fix assignment order for __counted_by
commit 585b90c upstream. Initialize fw_size before copying firmware data into the flexible array member to match the __counted_by() annotation. This fixes the incorrect assignment order that triggers runtime safety checks. Fixes: e9ed97b ("iio: proximity: hx9023s: Added firmware file parsing functionality") Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1657b99 commit 2c2661e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/iio/proximity/hx9023s.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,8 @@ static int hx9023s_send_cfg(const struct firmware *fw, struct hx9023s_data *data
10341034
if (!bin)
10351035
return -ENOMEM;
10361036

1037-
memcpy(bin->data, fw->data, fw->size);
1038-
10391037
bin->fw_size = fw->size;
1038+
memcpy(bin->data, fw->data, bin->fw_size);
10401039
bin->fw_ver = bin->data[FW_VER_OFFSET];
10411040
bin->reg_count = get_unaligned_le16(bin->data + FW_REG_CNT_OFFSET);
10421041

0 commit comments

Comments
 (0)