[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250403034520.59597-1-bsdhenrymartin@gmail.com>
Date: Thu, 3 Apr 2025 11:45:20 +0800
From: Henry Martin <bsdhenrymartin@...il.com>
To: dlemoal@...nel.org,
cassel@...nel.org,
linux-ide@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Henry Martin <bsdhenrymartin@...il.com>
Subject: [PATCH v1] [ARM] pata_pxa: Fix null-ptr-deref in pxa_ata_probe()
devm_ioremap() returns NULL on error. Currently, pxa_ata_probe() does
not check for this case, which results in a NULL pointer dereference.
Add NULL check after devm_ioremap() to prevent this issue.
Fixes: 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")
Signed-off-by: Henry Martin <bsdhenrymartin@...il.com>
---
drivers/ata/pata_pxa.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index 434f380114af..cc76290a3b1a 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -223,11 +223,16 @@ static int pxa_ata_probe(struct platform_device *pdev)
ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start,
resource_size(cmd_res));
+ if (!ap->ioaddr.cmd_addr)
+ return -ENOMEM;
ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
resource_size(ctl_res));
+ if (!ap->ioaddr.ctl_addr)
+ return -ENOMEM;
ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start,
resource_size(dma_res));
-
+ if (!ap->ioaddr.bmdma_addr)
+ return -ENOMEM;
/*
* Adjust register offsets
*/
--
2.34.1
Powered by blists - more mailing lists