[arch/arm/mach-mvebu] Question about kzalloc NULL check in i2c_quirk

Andrew Lunn andrew at lunn.ch
Wed Mar 20 18:10:36 PDT 2024


> > If we are out of memory at this point in the kernel boot, then what are
> > the chances of the kernel getting to the point where it can run
> > userspace?
> > 
> > I think that is the essence of Andrew's argument. A failure to allocate
> > memory here means there is a serious problem and the system won't boot
> > _even_ if we add something like:
> > 
> > 	if (!new_compat)
> > 		continue;
> > 
> > to that loop.
> > 
> 
> 
> Hi Andrew and Russell,
> 
> Thanks for pointing out the consequence! It makes sense and we will try to
> make our analyzer realize this as well. Thanks again for your time!

If you can make the analyzer realise this, that would be great.

If not, feel free to repost this patch, but please rework the commit
message. Point out that checking for NULL is pointless here, the
system is doomed. However, the static analysers cannot determine
that. And it makes sense to silence this pointless warning to stop it
hiding other real warning which could be real issues. "Cannot see the
forest because of the trees".

Something else to consider. The system is doomed. So maybe call
panic()?

	Andrew



More information about the linux-arm-kernel mailing list