Skip to content

Commit 4d43acb

Browse files
Dan Carpentervinodkoul
authored andcommitted
dmaengine: at_xdmac: fix potential Oops in at_xdmac_prep_interleaved()
There are two place if the at_xdmac_interleaved_queue_desc() fails which could lead to a NULL dereference where "first" is NULL and we call list_add_tail(&first->desc_node, ...). In the first caller, the return is not checked so add a check for that. In the next caller, the return is checked but if it fails on the first iteration through the loop then it will lead to a NULL pointer dereference. Fixes: 4e53857 ("dmaengine: at_xdmac: handle numf > 1") Fixes: 62b5cb7 ("dmaengine: at_xdmac: fix memory leak in interleaved mode") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Tudor Ambarus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 38de368 commit 4d43acb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/dma/at_xdmac.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
11021102
NULL,
11031103
src_addr, dst_addr,
11041104
xt, xt->sgl);
1105+
if (!first)
1106+
return NULL;
11051107

11061108
/* Length of the block is (BLEN+1) microblocks. */
11071109
for (i = 0; i < xt->numf - 1; i++)
@@ -1132,8 +1134,9 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
11321134
src_addr, dst_addr,
11331135
xt, chunk);
11341136
if (!desc) {
1135-
list_splice_tail_init(&first->descs_list,
1136-
&atchan->free_descs_list);
1137+
if (first)
1138+
list_splice_tail_init(&first->descs_list,
1139+
&atchan->free_descs_list);
11371140
return NULL;
11381141
}
11391142

0 commit comments

Comments
 (0)