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

* Re: [PATCH] ata: handle failure of devm_ioremap()
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Sergey Shtylyov @ 2022-06-12  9:06 UTC (permalink / raw)
  To: Li Qiong, Damien Le Moal
  Cc: linux-ide, linux-kernel, hukun, qixu, yuzhe, renyu

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

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

* Re: [PATCH] ata: handle failure of devm_ioremap()
  2022-06-12  9:06 ` Sergey Shtylyov
@ 2022-06-12 12:34   ` liqiong
  0 siblings, 0 replies; 5+ messages in thread
From: liqiong @ 2022-06-12 12:34 UTC (permalink / raw)
  To: Sergey Shtylyov, Damien Le Moal
  Cc: linux-ide, linux-kernel, hukun, qixu, yuzhe, renyu



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


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

* [PATCH v2] ata: pata_pxa: handle failure of devm_ioremap()
  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:57 ` Li Qiong
  2022-06-12 18:37   ` Sergei Shtylyov
  1 sibling, 1 reply; 5+ messages in thread
From: Li Qiong @ 2022-06-12 12:57 UTC (permalink / raw)
  To: Sergey Shtylyov, Damien Le Moal
  Cc: linux-ide, linux-kernel, 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>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v2:
- add driver's name (pata_pxa) to subject.
---
 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

* Re: [PATCH v2] ata: pata_pxa: handle failure of devm_ioremap()
  2022-06-12 12:57 ` [PATCH v2] ata: pata_pxa: " Li Qiong
@ 2022-06-12 18:37   ` Sergei Shtylyov
  0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2022-06-12 18:37 UTC (permalink / raw)
  To: Li Qiong, Sergey Shtylyov, Damien Le Moal
  Cc: linux-ide, linux-kernel, yuzhe, renyu

On 6/12/22 3:57 PM, 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>
> ---
> v2:
> - add driver's name (pata_pxa) to subject.
> ---
>  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));

   Looking again into this driver, this statement doesn't make sense: dma_res
points to a DMA resource, calling devm_ioremap() on it is just wrong... and
'ap->ioaddr.bmdma_addr' doesn;t seem to be used anyways...

MBR, Sergey

^ permalink raw reply	[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