diff options
author | Xiaotian Feng <dfeng@redhat.com> | 2010-05-25 21:51:10 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-05-26 14:26:04 -0400 |
commit | 20413f27163fb1b8b806c0c219dc95eae67c633a (patch) | |
tree | e40c22039a057bfed07598de0761deda166c8740 /arch/x86/mm/pat.c | |
parent | fe501f1e89cd460793152f500bf25d81d463515b (diff) |
x86, pat: Fix memory leak in free_memtype
Reserve_memtype will allocate memory for new memtype, but
in free_memtype, after the memtype erased from rbtree, the
memory is not freed.
Changes since V1:
make rbt_memtype_erase return erased memtype so that
it can be freed in free_memtype.
[ hpa: not for -stable: 2.6.34 and earlier not affected ]
Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
LKML-Reference: <1274838670-8731-1-git-send-email-dfeng@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Cc: Jack Steiner <steiner@sgi.com>
Acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/mm/pat.c')
-rw-r--r-- | arch/x86/mm/pat.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index bbe5502ee1cb..acc15b23b743 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -336,6 +336,7 @@ int free_memtype(u64 start, u64 end) | |||
336 | { | 336 | { |
337 | int err = -EINVAL; | 337 | int err = -EINVAL; |
338 | int is_range_ram; | 338 | int is_range_ram; |
339 | struct memtype *entry; | ||
339 | 340 | ||
340 | if (!pat_enabled) | 341 | if (!pat_enabled) |
341 | return 0; | 342 | return 0; |
@@ -355,17 +356,20 @@ int free_memtype(u64 start, u64 end) | |||
355 | } | 356 | } |
356 | 357 | ||
357 | spin_lock(&memtype_lock); | 358 | spin_lock(&memtype_lock); |
358 | err = rbt_memtype_erase(start, end); | 359 | entry = rbt_memtype_erase(start, end); |
359 | spin_unlock(&memtype_lock); | 360 | spin_unlock(&memtype_lock); |
360 | 361 | ||
361 | if (err) { | 362 | if (!entry) { |
362 | printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n", | 363 | printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n", |
363 | current->comm, current->pid, start, end); | 364 | current->comm, current->pid, start, end); |
365 | return -EINVAL; | ||
364 | } | 366 | } |
365 | 367 | ||
368 | kfree(entry); | ||
369 | |||
366 | dprintk("free_memtype request 0x%Lx-0x%Lx\n", start, end); | 370 | dprintk("free_memtype request 0x%Lx-0x%Lx\n", start, end); |
367 | 371 | ||
368 | return err; | 372 | return 0; |
369 | } | 373 | } |
370 | 374 | ||
371 | 375 | ||