Re: [PATCH 1/2] mailbox: add sanity check for channel array
From: Jassi Brar
Date: Sat Apr 18 2026 - 21:36:56 EST
On Sat, Apr 18, 2026 at 6:57 PM Wolfram Sang
<wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > This sounds like a quick suggestion from some AI tool -- looks nice
> > but doesn't mean much.
>
> Nope, from the cover letter:
>
> While diving deeper into this subsystem, I manually found these two
> issues which I wanted to fix right away.
>
> I just wanted to check which parameters are required and which are
> optional. And the array is definitely required, so the core should check
> for it IMHO.
>
I am saying that it is still not sufficient if we get so paranoid and
start doing what are basically static checks. What if the array at
chans is not NULL but less than num_chans?
num_chans check acts as the "required" indicator already.
> > point to an array of channels. NULL is just another garbage value, why
> > not also check for 0xdeadbabe or 0xffff... ?
>
> Because NULL is what we get if we kzalloc a structure unlike the values
> you mentioned.
>
Why can't the mbox structure be reused or be at some offset of a
bigger allocation? See, there is no end to theoretical dangers.
> > I can let loose a claude session and I will find 1000s of such "fixes"
> > in the kernel.
>
> No AI was involved in the generation of these patches. I think I marked
> the patches which resulted from AI review correctly so far.
>
To be clear, I am not against using AI tools. I use them myself. A lot.
All I am saying is its a slippery slope of "this check is good to
have, at least it doesn't hurt", with the AI tools we can generate
1000s of such patches that are only to "educate" the developer rather
than making any runtime difference.
Regards,
Jassi