linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Maxin B John <maxin.john@gmail.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	dima@android.com, eike-kernel@sf-tec.de, willy@linux.intel.com
Subject: [PATCH] mm: dmapool: fix possible use after free in dmam_pool_destroy()
Date: Thu, 2 Jun 2011 00:43:13 +0300	[thread overview]
Message-ID: <20110601214313.GA3724@maxin> (raw)

"dma_pool_destroy(pool)" calls "kfree(pool)". The freed pointer "pool"
is again passed as an argument to the function "devres_destroy()".
This patch fixes the possible use after free.

Please let me know your comments.

Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
diff --git a/mm/dmapool.c b/mm/dmapool.c
index 03bf3bb..fbb58e3 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -500,7 +500,7 @@ void dmam_pool_destroy(struct dma_pool *pool)
 {
 	struct device *dev = pool->dev;
 
-	dma_pool_destroy(pool);
 	WARN_ON(devres_destroy(dev, dmam_pool_release, dmam_pool_match, pool));
+	dma_pool_destroy(pool);
 }
 EXPORT_SYMBOL(dmam_pool_destroy);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2011-06-01 21:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 21:43 Maxin B John [this message]
2011-06-02  9:47 ` [PATCH] mm: dmapool: fix possible use after free in dmam_pool_destroy() Rolf Eike Beer
  -- strict thread matches above, loose matches on Subject: below --
2011-06-02 14:22 Maxin B John
2011-06-06  8:37 ` Maxin B John
2011-06-07 18:05   ` Rolf Eike Beer
2011-06-08 10:46     ` Maxin B John
2011-06-08 13:13       ` Rolf Eike Beer
2011-06-09 10:20 ` Tejun Heo

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=20110601214313.GA3724@maxin \
    --to=maxin.john@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dima@android.com \
    --cc=eike-kernel@sf-tec.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@linux.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).