Patchwork mtd: omap2: fix resource leak in prefetch-busy path

login
register
mail settings
Submitter Grazvydas Ignotas
Date April 11, 2012, 1:04 a.m.
Message ID <1334106274-24993-1-git-send-email-notasas@gmail.com>
Download mbox | patch
Permalink /patch/151722/
State Accepted
Commit d7efe2281db53544400ac83160a79cf8925598d9
Headers show

Comments

Grazvydas Ignotas - April 11, 2012, 1:04 a.m.
If prefetch engine is busy, current code "forgets" to call
dma_unmap_single(), which results in a deadlock later, so add it.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
 drivers/mtd/nand/omap2.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Artem Bityutskiy - April 22, 2012, 12:45 p.m.
On Wed, 2012-04-11 at 04:04 +0300, Grazvydas Ignotas wrote:
> If prefetch engine is busy, current code "forgets" to call
> dma_unmap_single(), which results in a deadlock later, so add it.
> 
> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>

Pushed to l2-mtd.git, thanks!

Patch

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index f745f00..7feb274 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -402,7 +402,7 @@  static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
 			PREFETCH_FIFOTHRESHOLD_MAX, 0x1, len, is_write);
 	if (ret)
 		/* PFPW engine is busy, use cpu copy method */
-		goto out_copy;
+		goto out_copy_unmap;
 
 	init_completion(&info->comp);
 
@@ -421,6 +421,8 @@  static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
 	dma_unmap_single(&info->pdev->dev, dma_addr, len, dir);
 	return 0;
 
+out_copy_unmap:
+	dma_unmap_single(&info->pdev->dev, dma_addr, len, dir);
 out_copy:
 	if (info->nand.options & NAND_BUSWIDTH_16)
 		is_write == 0 ? omap_read_buf16(mtd, (u_char *) addr, len)