Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 4e5385784e69 ("dmaengine: at_xdmac: handle numf > 1")
Fixes: 62b5cb757f1d ("dmaengine: at_xdmac: fix memory leak in interleaved mode")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/21282b66-9860-410a-83df-39c17fcf2f1b@kili.mountain
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dan Carpenter and committed by
Vinod Koul
4d43acb1 38de368a

+5 -2
+5 -2
drivers/dma/at_xdmac.c
··· 1102 1102 NULL, 1103 1103 src_addr, dst_addr, 1104 1104 xt, xt->sgl); 1105 + if (!first) 1106 + return NULL; 1105 1107 1106 1108 /* Length of the block is (BLEN+1) microblocks. */ 1107 1109 for (i = 0; i < xt->numf - 1; i++) ··· 1134 1132 src_addr, dst_addr, 1135 1133 xt, chunk); 1136 1134 if (!desc) { 1137 - list_splice_tail_init(&first->descs_list, 1138 - &atchan->free_descs_list); 1135 + if (first) 1136 + list_splice_tail_init(&first->descs_list, 1137 + &atchan->free_descs_list); 1139 1138 return NULL; 1140 1139 } 1141 1140