mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] [ARM] pata_pxa: Fix null-ptr-deref in pxa_ata_probe()
@ 2025-04-03  3:45 Henry Martin
  2025-04-03  7:33 ` [PATCH] " Markus Elfring
  2025-04-04  3:58 ` [PATCH v1] " Damien Le Moal
  0 siblings, 2 replies; 7+ messages in thread
From: Henry Martin @ 2025-04-03  3:45 UTC (permalink / raw)
  To: dlemoal, cassel, linux-ide; +Cc: linux-kernel, Henry Martin

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@gmail.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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-08  3:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03  3:45 [PATCH v1] [ARM] pata_pxa: Fix null-ptr-deref in pxa_ata_probe() Henry Martin
2025-04-03  7:33 ` [PATCH] " Markus Elfring
2025-04-04  3:58 ` [PATCH v1] " Damien Le Moal
2025-04-04  4:07   ` Damien Le Moal
2025-04-04  6:14     ` [PATCH v2] ata: pata_pxa: Fix potential NULL pointer dereference " Henry Martin
2025-04-04  9:22       ` Markus Elfring
2025-04-08  3:43       ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®