dmaengine: at_hdmac: Check return code of dma_async_device_register
authorTudor Ambarus <tudor.ambarus@microchip.com>
Tue, 25 Oct 2022 09:02:49 +0000 (12:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:35:38 +0000 (17:35 +0100)
commit c47e6403fa099f200868d6b106701cb42d181d2b upstream.

dma_async_device_register() can fail, check the return code and display an
error.

Fixes: dc78baa2b90b ("dmaengine: at_hdmac: new driver for the Atmel AHB DMA Controller")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Cc: stable@vger.kernel.org
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20221025090306.297886-1-tudor.ambarus@microchip.com
Link: https://lore.kernel.org/r/20221025090306.297886-16-tudor.ambarus@microchip.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/at_hdmac.c

index 50ef321c2a385001b567941f59c57cab3204b0ee..4a2c9a24b17303a996bcb6dbaa915b3fbc729e08 100644 (file)
@@ -2092,7 +2092,11 @@ static int __init at_dma_probe(struct platform_device *pdev)
          dma_has_cap(DMA_SG, atdma->dma_common.cap_mask)  ? "sg-cpy " : "",
          plat_dat->nr_channels);
 
-       dma_async_device_register(&atdma->dma_common);
+       err = dma_async_device_register(&atdma->dma_common);
+       if (err) {
+               dev_err(&pdev->dev, "Unable to register: %d.\n", err);
+               goto err_dma_async_device_register;
+       }
 
        /*
         * Do not return an error if the dmac node is not present in order to
@@ -2112,6 +2116,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
 
 err_of_dma_controller_register:
        dma_async_device_unregister(&atdma->dma_common);
+err_dma_async_device_register:
        dma_pool_destroy(atdma->memset_pool);
 err_memset_pool_create:
        dma_pool_destroy(atdma->dma_desc_pool);