dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: nbpfaxi: Fix possible array access out of bounds of nbpf->chan
@ 2025-07-07  8:23 Thomas Fourier
  2025-07-15 15:11 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2025-07-07  8:23 UTC (permalink / raw)
  Cc: Thomas Fourier, Vinod Koul, Guennadi Liakhovetski, dmaengine,
	linux-kernel

The nbpf is alloc'd at line 1324 with a size of num_channels so it seems
like the maximum index of nbpf->chan should be num_channels - 1.

Fixes: b45b262cefd5 ("dmaengine: add a driver for AMBA AXI NBPF DMAC IP cores")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/dma/nbpfaxi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
index 0b75bb122898..dd1b5e2a603c 100644
--- a/drivers/dma/nbpfaxi.c
+++ b/drivers/dma/nbpfaxi.c
@@ -1364,7 +1364,7 @@ static int nbpf_probe(struct platform_device *pdev)
 	if (irqs == 1) {
 		eirq = irqbuf[0];
 
-		for (i = 0; i <= num_channels; i++)
+		for (i = 0; i < num_channels; i++)
 			nbpf->chan[i].irq = irqbuf[0];
 	} else {
 		eirq = platform_get_irq_byname(pdev, "error");
@@ -1374,7 +1374,7 @@ static int nbpf_probe(struct platform_device *pdev)
 		if (irqs == num_channels + 1) {
 			struct nbpf_channel *chan;
 
-			for (i = 0, chan = nbpf->chan; i <= num_channels;
+			for (i = 0, chan = nbpf->chan; i < num_channels;
 			     i++, chan++) {
 				/* Skip the error IRQ */
 				if (irqbuf[i] == eirq)
@@ -1391,7 +1391,7 @@ static int nbpf_probe(struct platform_device *pdev)
 			else
 				irq = irqbuf[0];
 
-			for (i = 0; i <= num_channels; i++)
+			for (i = 0; i < num_channels; i++)
 				nbpf->chan[i].irq = irq;
 		}
 	}
-- 
2.43.0


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

* Re: [PATCH] dmaengine: nbpfaxi: Fix possible array access out of bounds of nbpf->chan
  2025-07-07  8:23 [PATCH] dmaengine: nbpfaxi: Fix possible array access out of bounds of nbpf->chan Thomas Fourier
@ 2025-07-15 15:11 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2025-07-15 15:11 UTC (permalink / raw)
  To: Thomas Fourier; +Cc: Guennadi Liakhovetski, dmaengine, linux-kernel

On 07-07-25, 10:23, Thomas Fourier wrote:
> The nbpf is alloc'd at line 1324 with a size of num_channels so it seems
> like the maximum index of nbpf->chan should be num_channels - 1.

I have already applied a patch from Dan sent earlier for this

> 
> Fixes: b45b262cefd5 ("dmaengine: add a driver for AMBA AXI NBPF DMAC IP cores")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
>  drivers/dma/nbpfaxi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
> index 0b75bb122898..dd1b5e2a603c 100644
> --- a/drivers/dma/nbpfaxi.c
> +++ b/drivers/dma/nbpfaxi.c
> @@ -1364,7 +1364,7 @@ static int nbpf_probe(struct platform_device *pdev)
>  	if (irqs == 1) {
>  		eirq = irqbuf[0];
>  
> -		for (i = 0; i <= num_channels; i++)
> +		for (i = 0; i < num_channels; i++)
>  			nbpf->chan[i].irq = irqbuf[0];
>  	} else {
>  		eirq = platform_get_irq_byname(pdev, "error");
> @@ -1374,7 +1374,7 @@ static int nbpf_probe(struct platform_device *pdev)
>  		if (irqs == num_channels + 1) {
>  			struct nbpf_channel *chan;
>  
> -			for (i = 0, chan = nbpf->chan; i <= num_channels;
> +			for (i = 0, chan = nbpf->chan; i < num_channels;
>  			     i++, chan++) {
>  				/* Skip the error IRQ */
>  				if (irqbuf[i] == eirq)
> @@ -1391,7 +1391,7 @@ static int nbpf_probe(struct platform_device *pdev)
>  			else
>  				irq = irqbuf[0];
>  
> -			for (i = 0; i <= num_channels; i++)
> +			for (i = 0; i < num_channels; i++)
>  				nbpf->chan[i].irq = irq;
>  		}
>  	}
> -- 
> 2.43.0

-- 
~Vinod

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

end of thread, other threads:[~2025-07-15 15:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07  8:23 [PATCH] dmaengine: nbpfaxi: Fix possible array access out of bounds of nbpf->chan Thomas Fourier
2025-07-15 15:11 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).