dma_request_chan() is expected to return ERR_PTR rather than NULL. This triggered a crash in pl011_dma_probe() when dma_device_list is empty and returning NULL. Fix return of NULL ptr to ERR_PTR(-ENODEV). Fixes: deb9541f5052 ("dmaengine: check device and channel list for empty") Reported-by: Arnd Bergmann <arnd@xxxxxxxx> Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> --- drivers/dma/dmaengine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 0d6529eff66f..48e159e83cf5 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -852,7 +852,7 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name) mutex_lock(&dma_list_mutex); if (list_empty(&dma_device_list)) { mutex_unlock(&dma_list_mutex); - return NULL; + return ERR_PTR(-ENODEV); } list_for_each_entry_safe(d, _d, &dma_device_list, global_node) {