summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2022-05-26 15:51:11 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-12 16:26:25 +0200
commitdeb71c0479584c7b5f0af8c8a9e3f42ad3f591b9 (patch)
tree208b70cf5c83235b6acdaede4815f6c9d6cec646
parenta0775288e8f0904ab1867e39d6d22122d1e8885d (diff)
dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly
commit 3770d92bd5237d686e49da7b2fb86f53ee6ed259 upstream. It seems that it is valid to have less than the requested number of descriptors. But what is not valid and leads to subsequent errors is to have zero descriptors. In that case, abort the probing. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20220526135111.1470926-1-michael@walle.cc Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/dma/at_xdmac.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index ca266fcca186..f191057065f7 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1806,6 +1806,11 @@ static int at_xdmac_alloc_chan_resources(struct dma_chan *chan)
for (i = 0; i < init_nr_desc_per_channel; i++) {
desc = at_xdmac_alloc_desc(chan, GFP_ATOMIC);
if (!desc) {
+ if (i == 0) {
+ dev_warn(chan2dev(chan),
+ "can't allocate any descriptors\n");
+ return -EIO;
+ }
dev_warn(chan2dev(chan),
"only %d descriptors have been allocated\n", i);
break;