On Thu, 17 Sep 2026 14:14:37 -0700
Kees Cook <[email protected]> wrote:

> From: Kees Cook <[email protected]>
> 
> In preparation for making the devm_kmalloc family of allocators type
> aware, we need to make sure that the returned type from the allocation
> matches the type of the variable being assigned. (Before, the allocator
> would always return "void *", which can be implicitly cast to any
> pointer type.)
> 
> The assigned type is "struct iio_chan_spec *", but the converted
> allocation type would be "const struct iio_chan_spec *", as the size was
> taken from "*indio_dev->channels", and "indio_dev->channels" points to
> const. As there is no general way to remove const qualifiers, take the
> size from the assignment target instead. No change in allocation size
> results.
> 
> Build tested ARCH=x86_64 allmodconfig with GCC 16.2.0:
> drivers/iio/adc/ad7173.o
> 
> Assisted-by: LLM coccinelle
> Signed-off-by: Kees Cook <[email protected]>
> ---

Makes sense.

Reviewed-by: Joshua Crofts <[email protected]>

-- 
Kind regards,
Joshua Crofts

Reply via email to