]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: proximity: hx9023s: fix assignment order for __counted_by
authorYasin Lee <yasin.lee.x@gmail.com>
Fri, 13 Feb 2026 15:14:43 +0000 (23:14 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 08:24:38 +0000 (08:24 +0000)
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: e9ed97be4fcc ("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>
drivers/iio/proximity/hx9023s.c

index 2918dfc0df547ceaf82e9c9f2a2c532444038a23..ad839db6b326b1abca6897ec84215e28fa0c4be2 100644 (file)
@@ -1034,9 +1034,8 @@ static int hx9023s_send_cfg(const struct firmware *fw, struct hx9023s_data *data
        if (!bin)
                return -ENOMEM;
 
-       memcpy(bin->data, fw->data, fw->size);
-
        bin->fw_size = fw->size;
+       memcpy(bin->data, fw->data, bin->fw_size);
        bin->fw_ver = bin->data[FW_VER_OFFSET];
        bin->reg_count = get_unaligned_le16(bin->data + FW_REG_CNT_OFFSET);