Re: [PATCH] ata: pata_platform: Fix a NULL pointer dereference in __pata_platform_probe()

From: Sergey Shtylyov
Date: Thu Jan 27 2022 - 04:37:26 EST


Hello!

On 1/27/22 5:15 AM, Damien Le Moal wrote:

>>> In __pata_platform_probe(), devm_kzalloc() is assigned to ap->ops and
>>> there is a dereference of it right after that, which could introduce a
>>> NULL pointer dereference bug.
>>>
>>> Fix this by adding a NULL check of ap->ops.
>>>
>>> This bug was found by a static analyzer.
>>>
>>> Builds with 'make allyesconfig' show no new warnings,
>>> and our static analyzer no longer warns about this code.
>>>
>>> Fixes: f3d5e4f18dba ("ata: pata_of_platform: Allow to use 16-bit wide data transfer")
>>> Signed-off-by: Zhou Qingyang <zhou1615@xxxxxxx>
>>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@xxxxxx>
>
> Please see my note about the typo in the fix. I kept you RB tag. Let me

Oops, didn't expect such a stupid bug, so my brain did add the missing ! prolly... :-)
Not clear how he managed to shut up his static analyzer with this patch...

> know if that is OK.

Of course, sorry for the messy review! :-)

>> [...]

MBR, Sergey