Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / drivers / dma / edma.c
index cd8da451d1995fef8b6d076005b17ad1a17b44d1..cd04eb7b182e338994f03f8f1d1f84c28d49fc40 100644 (file)
@@ -539,6 +539,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
                                edma_alloc_slot(EDMA_CTLR(echan->ch_num),
                                                EDMA_SLOT_ANY);
                        if (echan->slot[i] < 0) {
+                               kfree(edesc);
                                dev_err(dev, "Failed to allocate slot\n");
                                return NULL;
                        }
@@ -553,8 +554,10 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
                ret = edma_config_pset(chan, &edesc->pset[i], src_addr,
                                       dst_addr, burst, dev_width, period_len,
                                       direction);
-               if (ret < 0)
+               if (ret < 0) {
+                       kfree(edesc);
                        return NULL;
+               }
 
                if (direction == DMA_DEV_TO_MEM)
                        dst_addr += period_len;