Re: [PATCH v2] iio: proximity: hx9023s: validate firmware size

From: Andy Shevchenko

Date: Sat Jul 11 2026 - 05:03:45 EST


On Fri, Jul 10, 2026 at 01:21:51PM -0700, Jonathan Cameron wrote:
> On Fri, 10 Jul 2026 21:13:42 +0545
> Laxman Acharya Padhya <acharyalaxman8848@xxxxxxxxx> wrote:

...

> > struct hx9023s_bin *bin __free(kfree) =
> > - kzalloc(fw->size + sizeof(*bin), GFP_KERNEL);
> > + kzalloc(sizeof(*bin) + fw->size, GFP_KERNEL);
>
> This doesn't belong in the fix given it is just a reorder. Maybe it makes sense
> but if it does, separate patch with an explanation of why.

Semantically this should use struct_size() which brings us to the kzalloc_flex().
And this will be a separate patch.

> > if (!bin)
> > return -ENOMEM;

--
With Best Regards,
Andy Shevchenko