Re: [PATCH] iio: adc: ad7173: Remove const from chan_arr allocation type
From: Joshua Crofts
Date: Fri Sep 18 2026 - 02:54:27 EST
On Thu, 17 Sep 2026 14:14:37 -0700
Kees Cook <kees@xxxxxxxxxx> wrote:
> From: Kees Cook <kees+treewide@xxxxxxxxxx>
>
> 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 <kees+treewide@xxxxxxxxxx>
> ---
Makes sense.
Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
--
Kind regards,
Joshua Crofts