pata_pxa: Fix null-ptr-deref in pxa_ata_probe()
PATCH 1/1 pata_pxa: Fix null-ptr-deref in pxa_ata_probe()
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.
--- drivers/ata/pata_pxa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ata/pata_pxa.c +6 -1
@@ -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 */
Signature · 1 line
2.34.1
…
Quoted 1 line
Add NULL check after
devm_ioremap()to prevent this issue.
Can a summary phrase like “Prevent null pointer dereference in pxa_ata_probe()” be a bit nicer?
…
drivers/ata/pata_pxa.c static int pxa_ata_probe(struct platform_device *pdev) · line 227
Quoted 7 lines
+++
b/drivers/ata/pata_pxa.cdrivers/ata/pata_pxa.c +2
-0@@ -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 ;
Can a blank line be desirable after such a statement?
Regards,
Markus
Damien Le Moal
maintainerQuoted 2 lines · 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.
, which can result in...
Quoted 18 lines
Add NULL check after
devm_ioremap()to prevent this issue.Fixes 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")Signed-off-by Henry Martin <[email protected]>--- drivers/ata/pata_pxa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/ata/pata_pxa.c +1
-0@@ -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)
drivers/ata/pata_pxa.c static int pxa_ata_probe(struct platform_device *pdev) · line 235
Quoted 10 lines
drivers/ata/pata_pxa.c +5
-1+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 ;
Please keep the blank line here.
Quoted 3 lines
drivers/ata/pata_pxa.c +0
-0/* * Adjust register offsets */
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien Le Moal
maintainerQuoted 1 line · Damien Le Moal
On 4/3/25 12:45 PM, Henry Martin wrote:
The patch title should be:
ata: pata_pxa: Fix potential NULL pointer dereference in pxa_ata_probe()
Quoted 41 lines
Quoted 2 lines
devm_ioremap()returns NULL on error. Currently,pxa_ata_probe()does not check for this case, which results in a NULL pointer dereference., which can result in...
Quoted 18 lines
Add NULL check after
devm_ioremap()to prevent this issue.Fixes 2dc6c6f15da9 ("[ARM] pata_pxa: DMA-capable PATA driver")Signed-off-by Henry Martin <[email protected]>--- drivers/ata/pata_pxa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/ata/pata_pxa.c +1
-0@@ -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)drivers/ata/pata_pxa.c static int pxa_ata_probe(struct platform_device *pdev) · line 235
Quoted 10 lines
drivers/ata/pata_pxa.c +5
-1+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 ;Please keep the blank line here.
Quoted 3 lines
drivers/ata/pata_pxa.c +0
-0/* * Adjust register offsets */
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH v2 1/1 ata: pata_pxa: Fix potential NULL pointer dereference in pxa_ata_probe()
devm_ioremap() returns NULL on error. Currently, pxa_ata_probe() does not check for this case, which can result in a NULL pointer dereference.
Add NULL check after devm_ioremap() to prevent this issue.
---
V1 -> V2: Correct commit message and keep a blank line after check.
drivers/ata/pata_pxa.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ata/pata_pxa.c +6 -0
@@ -223,10 +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
Signature · 1 line
2.34.1
Re: [PATCH v2] ata: pata_pxa: Fix potential NULL pointer dereference in pxa_ata_probe()
…
Quoted 1 line
Add NULL check after
devm_ioremap()to prevent this issue.
May you omit the word “potential” from the summary phrase?
…
Quoted 2 lines
---
V1 -> V2: Correct commit message and keep a blank line after check.
Can such an adjustment become helpful for any more places?
Regards,
Markus
Re: [PATCH v2] ata: pata_pxa: Fix potential NULL pointer dereference in pxa_ata_probe()
In reply to Henry MartinQuoted 7 lines · Henry Martin
devm_ioremap()returns NULL on error. Currently,pxa_ata_probe()does not check for this case, which can result 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 <[email protected]>
Applied to for-6.15-fixes. Thanks !
Signature · 2 lines
Damien Le Moal Western Digital Research