public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ata: handle failure of devm_ioremap()
@ 2022-06-12  7:32 Li Qiong
  2022-06-12  9:06 ` Sergey Shtylyov
  2022-06-12 12:57 ` [PATCH v2] ata: pata_pxa: " Li Qiong
  0 siblings, 2 replies; 5+ messages in thread
From: Li Qiong @ 2022-06-12  7:32 UTC (permalink / raw)
  To: Sergey Shtylyov, Damien Le Moal
  Cc: linux-ide, linux-kernel, hukun, qixu, yuzhe, renyu, Li Qiong

As the possible failure of the devm_ioremap(), the return value
could be NULL. Therefore it should be better to check it and
print error message, return '-ENOMEM' error code.

Signed-off-by: Li Qiong <liqiong@nfschina.com>
---
 drivers/ata/pata_pxa.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index 985f42c4fd70..cd1a8f37f920 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -228,6 +228,11 @@ static int pxa_ata_probe(struct platform_device *pdev)
 	ap->ioaddr.bmdma_addr	= devm_ioremap(&pdev->dev, dma_res->start,
 						resource_size(dma_res));
 
+	if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr || !ap->ioaddr.bmdma_addr) {
+		dev_err(&pdev->dev, "failed to map ap->ioaddr\n");
+		return -ENOMEM;
+	}
+
 	/*
 	 * Adjust register offsets
 	 */
-- 
2.11.0


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

end of thread, other threads:[~2022-06-12 18:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-12  7:32 [PATCH] ata: handle failure of devm_ioremap() Li Qiong
2022-06-12  9:06 ` Sergey Shtylyov
2022-06-12 12:34   ` liqiong
2022-06-12 12:57 ` [PATCH v2] ata: pata_pxa: " Li Qiong
2022-06-12 18:37   ` Sergei Shtylyov

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