diff mbox series

[-next] ide: add the return pointer check for plat_ide_probe

Message ID 20200918125645.17309-1-zhangqilong3@huawei.com
State Under Review
Delegated to: David Miller
Headers show
Series [-next] ide: add the return pointer check for plat_ide_probe | expand

Commit Message

Zhang Qilong Sept. 18, 2020, 12:56 p.m. UTC
From: Zhang Qilong <zhangqilong3@huawei.com>

If io map failed in devm_ioremap/devm_ioport_map, base
or alt_base will be null, it will cause setup port error
later but it won't be found out in plat_ide_setup_ports.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/ide/ide_platform.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c
index 91639fd6c276..fdbc565ef142 100644
--- a/drivers/ide/ide_platform.c
+++ b/drivers/ide/ide_platform.c
@@ -86,6 +86,11 @@  static int plat_ide_probe(struct platform_device *pdev)
 			res_alt->start, resource_size(res_alt));
 	}
 
+	if (!base || !alt_base) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
 	memset(&hw, 0, sizeof(hw));
 	plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start);
 	hw.dev = &pdev->dev;