All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Xiaotian Feng <dfeng@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>,
	Jack Steiner <steiner@sgi.com>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Marcin Slusarz <marcin.slusarz@gmail.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: [patch] x86, pat: freeing invalid memtype messages
Date: Thu, 17 Jun 2010 15:45:59 +0200	[thread overview]
Message-ID: <20100617134559.GA29824@bicker> (raw)

Commit 20413f27163 "x86, pat: Fix memory leak in free_memtype" added an
error message in free_memtype() if rbt_memtype_erase() returns NULL.  
The problem is that if CONFIG_X86_PAT is enabled, we use a different
implimentation of rbt_memtype_erase() that always returns NULL.

I've modified rbt_memtype_erase() to return an ERR_PTR() on errors and 
made free_memtype() check for that instead.

Addresses:  https://bugzilla.kernel.org/show_bug.cgi?id=16205

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index acc15b2..81b7735 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -359,10 +359,10 @@ int free_memtype(u64 start, u64 end)
 	entry = rbt_memtype_erase(start, end);
 	spin_unlock(&memtype_lock);
 
-	if (!entry) {
+	if (IS_ERR(entry)) {
 		printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n",
 			current->comm, current->pid, start, end);
-		return -EINVAL;
+		return PTR_ERR(entry);
 	}
 
 	kfree(entry);
diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
index f537087..90e5cbe 100644
--- a/arch/x86/mm/pat_rbtree.c
+++ b/arch/x86/mm/pat_rbtree.c
@@ -236,8 +236,10 @@ struct memtype *rbt_memtype_erase(u64 start, u64 end)
 	struct memtype *data;
 
 	data = memtype_rb_exact_match(&memtype_rbroot, start, end);
-	if (!data)
+	if (!data) {
+		data = ERR_PTR(-EINVAL);
 		goto out;
+	}
 
 	rb_erase(&data->rb, &memtype_rbroot);
 out:



             reply	other threads:[~2010-06-17 13:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 13:45 Dan Carpenter [this message]
2010-06-17 16:17 ` [patch] x86, pat: freeing invalid memtype messages Marcin Slusarz
2010-06-17 16:33   ` Dan Carpenter
2010-06-18  1:58   ` Xiaotian Feng
2010-06-18  6:47   ` Xiaotian Feng
2010-06-18 17:57     ` Marcin Slusarz
2010-06-21 10:56       ` Xiaotian Feng
2010-06-21 11:02         ` Peter Zijlstra
2010-06-21 11:07           ` Xiaotian Feng
2010-06-21 15:33             ` Marcin Slusarz
2010-06-21 15:41               ` Peter Zijlstra
2010-06-21 17:54                 ` Suresh Siddha
2010-06-21 18:08                   ` Venkatesh Pallipadi
2010-06-21 18:38                     ` Venkatesh Pallipadi
2010-06-21 18:41                       ` Marcin Slusarz
2010-06-21 18:56                         ` Marcin Slusarz
2010-06-22  2:45                   ` Xiaotian Feng
2010-06-22  3:47                     ` Venkatesh Pallipadi

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=20100617134559.GA29824@bicker \
    --to=error27@gmail.com \
    --cc=dfeng@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=mingo@redhat.com \
    --cc=steiner@sgi.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=venkatesh.pallipadi@intel.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.