Skip to contentSkip to conversation

mm/ksm: return NULL when doesn't get mergeable page

PATCH In review Jianguo Wu 2 participants 3 messages Sep 16, 2013 – Sep 22, 2013

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 1/1 mm/ksm: return NULL when doesn't get mergeable page

In get_mergeable_page() local variable page is not initialized, it may hold a garbage value, when find_mergeable_vma() return NULL, get_mergeable_page() may return a garbage value to the caller.

So initialize page as NULL.

---
 mm/ksm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/ksm.c +1 -1
index b6afe0c..87efbae 100644
@@ -460,7 +460,7 @@ static struct page *get_mergeable_page(struct rmap_item *rmap_item)
 	struct mm_struct *mm = rmap_item->mm;
 	unsigned long addr = rmap_item->address;
 	struct vm_area_struct *vma;
-	struct page *page;
+	struct page *page = NULL;
 
 	down_read(&mm->mmap_sem);
 	vma = find_mergeable_vma(mm, addr);
Signature · 8 lines
1.7.1


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 27 lines · Jianguo Wu

In get_mergeable_page() local variable page is not initialized, it may hold a garbage value, when find_mergeable_vma() return NULL, get_mergeable_page() may return a garbage value to the caller.

So initialize page as NULL.

---
 mm/ksm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/ksm.c +1 -1
index b6afe0c..87efbae 100644
@@ -460,7 +460,7 @@ static struct page *get_mergeable_page(struct rmap_item *rmap_item)
 	struct mm_struct *mm = rmap_item->mm;
 	unsigned long addr = rmap_item->address;
 	struct vm_area_struct *vma;
-	struct page *page;
+	struct page *page = NULL;
 
 	down_read(&mm->mmap_sem);
 	vma = find_mergeable_vma(mm, addr);
Signature · 1 line
1.7.1

When find_mergeable_vma returned NULL, NULL is assigned to page in "out" statement.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 23 lines · Petr Holasek
Quoted 22 lines · Jianguo Wu

In get_mergeable_page() local variable page is not initialized, it may hold a garbage value, when find_mergeable_vma() return NULL, get_mergeable_page() may return a garbage value to the caller.

So initialize page as NULL.

---
 mm/ksm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/ksm.c +1 -1
index b6afe0c..87efbae 100644
@@ -460,7 +460,7 @@ static struct page *get_mergeable_page(struct rmap_item *rmap_item)
 	struct mm_struct *mm = rmap_item->mm;
 	unsigned long addr = rmap_item->address;
 	struct vm_area_struct *vma;
-	struct page *page;
+	struct page *page = NULL;
 
Quoted 9 lines
Quoted 5 lines
mm/ksm.c +0 -0
 	down_read(&mm->mmap_sem);
 	vma = find_mergeable_vma(mm, addr);
Signature · 1 line
1.7.1

When find_mergeable_vma returned NULL, NULL is assigned to page in "out" statement.

Oh, yes, thanks, Petr.

Quoted 1 line

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>