Skip to content

Commit

Permalink
drivers/base dmam_declare_coherent_memory leaks
Browse files Browse the repository at this point in the history
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 <uvv.mail@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
UVV-gh authored and gregkh committed Aug 31, 2016
1 parent e330b9a commit 775115c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/base/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 775115c

Please sign in to comment.