Skip to content

Commit 62a277d

Browse files
GustavoARSilvaVinod Koul
authored andcommitted
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: 4483320 ("dmaengine: Use Pointer xt after NULL check.") Signed-off-by: Gustavo A. R. Silva <[email protected]> Acked-by: Ludovic Desroches <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
1 parent 5c9afbd commit 62a277d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/dma/at_hdmac.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
708708
unsigned long flags)
709709
{
710710
struct at_dma_chan *atchan = to_at_dma_chan(chan);
711-
struct data_chunk *first = xt->sgl;
711+
struct data_chunk *first;
712712
struct at_desc *desc = NULL;
713713
size_t xfer_count;
714714
unsigned int dwidth;
@@ -720,6 +720,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
720720
if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
721721
return NULL;
722722

723+
first = xt->sgl;
724+
723725
dev_info(chan2dev(chan),
724726
"%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
725727
__func__, &xt->src_start, &xt->dst_start, xt->numf,

0 commit comments

Comments
 (0)