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

Zijie Zhao zzjas98 at gmail.com
Wed Mar 20 18:22:43 PDT 2024


On 3/20/24 8:10 PM, Andrew Lunn wrote:
>>> 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

Hi Andrew,

Thanks for considering help our analyzer. We examined more similar 
cases and found there are a few other locations where OOM equals dead 
system, so it would probably be better to improve the analyzer instead 
of adding more checks.

Thanks again for the information and your time!

Best,
Zijie



More information about the linux-arm-kernel mailing list