From: Michael Walle Date: Thu, 26 May 2022 13:51:11 +0000 (+0200) Subject: dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly X-Git-Tag: baikal/mips/sdk5.9~1351 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=c886bdaaed80933c62efe7e1fa60cf0c528ab304;p=kernel.git dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly commit 91b185c18170abcf3aea632e9ef43b3fb67600a9 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: ac70d1d8dc5d ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Michael Walle Link: https://lore.kernel.org/r/20220526135111.1470926-1-michael@walle.cc Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 177a537971a1b..c5638afe94368 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1898,6 +1898,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_KERNEL); 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;