diff mbox series

ata: handle failure of devm_ioremap()

Message ID 20220612073222.18974-1-liqiong@nfschina.com
State New
Headers show
Series ata: handle failure of devm_ioremap() | expand

Commit Message

Li Qiong June 12, 2022, 7:32 a.m. UTC
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(+)

Comments

Sergey Shtylyov June 12, 2022, 9:06 a.m. UTC | #1
Hello!

   The subject should include the driver's name, like below:

ata: pata_pxa: handle failure of devm_ioremap()

On 6/12/22 10:32 AM, Li Qiong wrote:

> 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>


Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey
Li Qiong June 12, 2022, 12:34 p.m. UTC | #2
在 2022年06月12日 17:06, Sergey Shtylyov 写道:
> Hello!
>
>    The subject should include the driver's name, like below:
>
> ata: pata_pxa: handle failure of devm_ioremap()
>
> On 6/12/22 10:32 AM, Li Qiong wrote:
>
>> 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>
>
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>
> [...]
>
> MBR, Sergey

Thanks, I will submit a v2 patch.
diff mbox series

Patch

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
 	 */