Skip to contentSkip to conversation

dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved

PATCH Applied Gustavo A. R. Silva 3 participants 3 messages Nov 20, 2017 – Nov 29, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved

_xt_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference.

Fix this by moving the pointer dereference after _xt_ has been null checked.

This issue was detected with the help of Coccinelle.

Fixes 4483320e241c ("dmaengine: Use Pointer xt after NULL check.")
---
 drivers/dma/at_hdmac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/at_hdmac.c +3 -1
index fbab271..a861b5b 100644
@@ -708,7 +708,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
 			 unsigned long flags)
 {
 	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
-	struct data_chunk	*first = xt->sgl;
+	struct data_chunk	*first;
 	struct at_desc		*desc = NULL;
 	size_t			xfer_count;
 	unsigned int		dwidth;
@@ -720,6 +720,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
 	if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
 		return NULL;
 
+	first = xt->sgl;
+
 	dev_info(chan2dev(chan),
 		 "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
 		__func__, &xt->src_start, &xt->dst_start, xt->numf,
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Gustavo A. R. Silva

_xt_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference.

Fix this by moving the pointer dereference after _xt_ has been null checked.

This issue was detected with the help of Coccinelle.

Fixes 4483320e241c ("dmaengine: Use Pointer xt after NULL check.")

Thanks

Quoted 34 lines
---
 drivers/dma/at_hdmac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/at_hdmac.c +3 -1
index fbab271..a861b5b 100644
@@ -708,7 +708,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
 			 unsigned long flags)
 {
 	struct at_dma_chan	*atchan = to_at_dma_chan(chan);
-	struct data_chunk	*first = xt->sgl;
+	struct data_chunk	*first;
 	struct at_desc		*desc = NULL;
 	size_t			xfer_count;
 	unsigned int		dwidth;
@@ -720,6 +720,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
 	if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
 		return NULL;
 
+	first = xt->sgl;
+
 	dev_info(chan2dev(chan),
 		 "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
 		__func__, &xt->src_start, &xt->dst_start, xt->numf,
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Applied
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 7 lines · Gustavo A. R. Silva

_xt_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference.

Fix this by moving the pointer dereference after _xt_ has been null checked.

This issue was detected with the help of Coccinelle.

Applied, thanks

Signature · 1 line
~Vinod