From: Vyacheslav V. Yurkov Date: Tue, 14 Jun 2016 07:58:37 +0000 (+0200) Subject: drivers/base dmam_declare_coherent_memory leaks X-Git-Tag: v4.9-rc1~148^2~12 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=775115c06091fcfa1189a50aca488fa596839617;p=karo-tx-linux.git drivers/base dmam_declare_coherent_memory leaks dmam_declare_coherent_memory doesn't take into account the return value of dma_declare_coherent_memory, which leads to incorrect resource handling Signed-off-by: Vyacheslav V. Yurkov Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index 2e318ffa019e..8f8b68c80986 100644 --- a/drivers/base/dma-mapping.c +++ b/drivers/base/dma-mapping.c @@ -198,10 +198,13 @@ int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size, flags); - if (rc == 0) + if (rc) { devres_add(dev, res); - else + rc = 0; + } else { devres_free(res); + rc = -ENOMEM; + } return rc; }