diff options
author | Zhou Qingyang <zhou1615@umn.edu> | 2022-01-25 00:45:25 +0800 |
---|---|---|
committer | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-01-27 11:22:43 +0900 |
commit | 9b6d90e2085ca2ce72ef9ea78658bf270855e62e (patch) | |
tree | f79dd7bee1b66542dc25231a861607aa07846e1f /drivers | |
parent | 0280e3c58f92b2fe0e8fbbdf8d386449168de4a8 (diff) | |
download | linux-stable-9b6d90e2085ca2ce72ef9ea78658bf270855e62e.tar.gz |
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: f3d5e4f18dba ("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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/pata_platform.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 028329428b75..87c7c90676ca 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c @@ -128,6 +128,8 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res, ap = host->ports[0]; ap->ops = devm_kzalloc(dev, sizeof(*ap->ops), GFP_KERNEL); + if (!ap->ops) + return -ENOMEM; ap->ops->inherits = &ata_sff_port_ops; ap->ops->cable_detect = ata_cable_unknown; ap->ops->set_mode = pata_platform_set_mode; |