dmaengine: edma: Check the memory allocation for the memcpy dma device
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Wed, 21 Mar 2018 08:30:22 +0000 (10:30 +0200)
committerVinod Koul <vinod.koul@intel.com>
Tue, 27 Mar 2018 12:13:42 +0000 (17:43 +0530)
If the allocation fails then disable the memcpy support.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/edma.c

index 948df1a..85ea92f 100644 (file)
@@ -1876,6 +1876,11 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode)
 
        if (memcpy_channels) {
                m_ddev = devm_kzalloc(ecc->dev, sizeof(*m_ddev), GFP_KERNEL);
+               if (!m_ddev) {
+                       dev_warn(ecc->dev, "memcpy is disabled due to OoM\n");
+                       memcpy_channels = NULL;
+                       goto ch_setup;
+               }
                ecc->dma_memcpy = m_ddev;
 
                dma_cap_zero(m_ddev->cap_mask);
@@ -1903,6 +1908,7 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode)
                dev_info(ecc->dev, "memcpy is disabled\n");
        }
 
+ch_setup:
        for (i = 0; i < ecc->num_channels; i++) {
                struct edma_chan *echan = &ecc->slave_chans[i];
                echan->ch_num = EDMA_CTLR_CHAN(ecc->id, i);