]> git.baikalelectronics.ru Git - kernel.git/commit
ata: pata_platform: Fix a NULL pointer dereference in __pata_platform_probe()
authorZhou Qingyang <zhou1615@umn.edu>
Mon, 24 Jan 2022 16:45:25 +0000 (00:45 +0800)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Thu, 27 Jan 2022 02:22:43 +0000 (11:22 +0900)
commiteffe13f2a9a7e148cc5dc2ec7f5c97d1e251e85f
treef79dd7bee1b66542dc25231a861607aa07846e1f
parent3321ce0dfe1f09715eb0b138969ce6047c95f243
ata: pata_platform: Fix a NULL pointer dereference in __pata_platform_probe()

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: e548cf658b8e ("ata: pata_of_platform: Allow to use 16-bit wide data transfer")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
drivers/ata/pata_platform.c