mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ata: pata_pxa: Add missing check for devm_ioremap
@ 2023-02-09  9:28 Jiasheng Jiang
  2023-02-09  9:54 ` Sergey Shtylyov
  2023-02-09  9:54 ` Sergey Shtylyov
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2023-02-09  9:28 UTC (permalink / raw)
  To: s.shtylyov, damien.lemoal; +Cc: linux-ide, linux-kernel, Jiasheng Jiang

Add the check for the return value of the devm_ioremap in order to avoid
NULL pointer dereference.

Fixes: 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/ata/pata_pxa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index 985f42c4fd70..a20bb0824573 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -227,6 +227,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
 						resource_size(ctl_res));
 	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)
+		return -ENOMEM;
 
 	/*
 	 * Adjust register offsets
-- 
2.25.1


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

* Re: [PATCH] ata: pata_pxa: Add missing check for devm_ioremap
  2023-02-09  9:28 [PATCH] ata: pata_pxa: Add missing check for devm_ioremap Jiasheng Jiang
@ 2023-02-09  9:54 ` Sergey Shtylyov
  2023-02-09  9:54 ` Sergey Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2023-02-09  9:54 UTC (permalink / raw)
  To: Jiasheng Jiang, damien.lemoal; +Cc: linux-ide, linux-kernel

On 2/9/23 12:28 PM, Jiasheng Jiang wrote:

> Add the check for the return value of the devm_ioremap in order to avoid
> NULL pointer dereference.
> 
> Fixes: 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/ata/pata_pxa.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
> index 985f42c4fd70..a20bb0824573 100644
> --- a/drivers/ata/pata_pxa.c
> +++ b/drivers/ata/pata_pxa.c
> @@ -227,6 +227,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
>  						resource_size(ctl_res));
>  	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)
> +		return -ENOMEM;

   Such patch has been postyed already but the driver is more broken than just
ths check missing, see:

https://lore.kernel.org/all/20220612073222.18974-1-liqiong@nfschina.com/

MBR, Sergey

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

* Re: [PATCH] ata: pata_pxa: Add missing check for devm_ioremap
  2023-02-09  9:28 [PATCH] ata: pata_pxa: Add missing check for devm_ioremap Jiasheng Jiang
  2023-02-09  9:54 ` Sergey Shtylyov
@ 2023-02-09  9:54 ` Sergey Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2023-02-09  9:54 UTC (permalink / raw)
  To: Jiasheng Jiang, damien.lemoal; +Cc: linux-ide, linux-kernel

On 2/9/23 12:28 PM, Jiasheng Jiang wrote:

> Add the check for the return value of the devm_ioremap in order to avoid
> NULL pointer dereference.
> 
> Fixes: 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/ata/pata_pxa.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
> index 985f42c4fd70..a20bb0824573 100644
> --- a/drivers/ata/pata_pxa.c
> +++ b/drivers/ata/pata_pxa.c
> @@ -227,6 +227,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
>  						resource_size(ctl_res));
>  	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)
> +		return -ENOMEM;

   Such patch has been posted already but the driver is more broken than just
this check missing, see:

https://lore.kernel.org/all/20220612073222.18974-1-liqiong@nfschina.com/

MBR, Sergey

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

end of thread, other threads:[~2023-02-09  9:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09  9:28 [PATCH] ata: pata_pxa: Add missing check for devm_ioremap Jiasheng Jiang
2023-02-09  9:54 ` Sergey Shtylyov
2023-02-09  9:54 ` Sergey Shtylyov

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®