linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: <xuelin.shi@freescale.com>
To: <vinod.koul@intel.com>, <dan.j.williams@intel.com>,
	<linuxppc-dev@lists.ozlabs.org>
Cc: dmaengine@vger.kernel.org, Xuelin Shi <xuelin.shi@freescale.com>
Subject: [PATCH] fix dmaengine_unmap failure.
Date: Tue, 18 Mar 2014 16:32:00 +0800	[thread overview]
Message-ID: <1395131520-30207-1-git-send-email-xuelin.shi@freescale.com> (raw)

From: Xuelin Shi <xuelin.shi@freescale.com>

The count which is used to get_unmap_data maybe not the same as the
count computed in dmaengine_unmap which causes to free data in a
wrong pool.

This patch fixes this issue by keeping the pool in unmap_data
structure.

Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com>
---
 drivers/dma/dmaengine.c   | 7 +++++--
 include/linux/dmaengine.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ed610b4..2977eee 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1014,7 +1014,7 @@ static void dmaengine_unmap(struct kref *kref)
 		dma_unmap_page(dev, unmap->addr[i], unmap->len,
 			       DMA_BIDIRECTIONAL);
 	}
-	mempool_free(unmap, __get_unmap_pool(cnt)->pool);
+	mempool_free(unmap, unmap->unmap_pool->pool);
 }
 
 void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap)
@@ -1071,14 +1071,17 @@ struct dmaengine_unmap_data *
 dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
 {
 	struct dmaengine_unmap_data *unmap;
+	struct dmaengine_unmap_pool *unmap_pool;
 
-	unmap = mempool_alloc(__get_unmap_pool(nr)->pool, flags);
+	unmap_pool = __get_unmap_pool(nr);
+	unmap = mempool_alloc(unmap_pool->pool, flags);
 	if (!unmap)
 		return NULL;
 
 	memset(unmap, 0, sizeof(*unmap));
 	kref_init(&unmap->kref);
 	unmap->dev = dev;
+	unmap->unmap_pool = unmap_pool;
 
 	return unmap;
 }
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c5c92d5..6a25635 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -439,6 +439,7 @@ struct dmaengine_unmap_data {
 	struct device *dev;
 	struct kref kref;
 	size_t len;
+	struct dmaengine_unmap_pool *unmap_pool;
 	dma_addr_t addr[0];
 };
 
-- 
1.8.3.2

             reply	other threads:[~2014-03-18  9:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18  8:32 xuelin.shi [this message]
2014-03-18 17:13 ` [PATCH] fix dmaengine_unmap failure Dan Williams
2014-03-19  6:39   ` Xuelin Shi
2014-03-19 15:43     ` Dan Williams
2014-03-20  6:34       ` Xuelin Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395131520-30207-1-git-send-email-xuelin.shi@freescale.com \
    --to=xuelin.shi@freescale.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).