Skip to contentSkip to conversation

mm: avoid uninitialized variable in tracepoint

PATCH In review Arnd Bergmann 4 participants 4 messages Jan 18, 2016 – Jan 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: avoid uninitialized variable in tracepoint

A newly added tracepoint in the hugepage code uses a variable in the error handling that is not initialized at that point:

include/trace/events/huge_memory.h:81:230: error: 'isolated' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The result is relatively harmless, as the trace data will in rare cases contain incorrect data.

This works around the problem by adding an explicit initialization.

Fixes 7d2eba0557c1 ("mm: add tracepoint for scanning pages")
mm/huge_memory.c +1 -1
index b2db98136af9..bb3b763b1829 100644
@@ -2320,7 +2320,7 @@ static void collapse_huge_page(struct mm_struct *mm,
 	pgtable_t pgtable;
 	struct page *new_page;
 	spinlock_t *pmd_ptl, *pte_ptl;
-	int isolated, result = 0;
+	int isolated = 0, result = 0;
 	unsigned long hstart, hend;
 	struct mem_cgroup *memcg;
 	unsigned long mmun_start;	/* For mmu_notifiers */
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnd Bergmann

A newly added tracepoint in the hugepage code uses a variable in the error handling that is not initialized at that point:

include/trace/events/huge_memory.h:81:230: error: 'isolated' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

The result is relatively harmless, as the trace data will in rare cases contain incorrect data.

This works around the problem by adding an explicit initialization.

Fixes 7d2eba0557c1 ("mm: add tracepoint for scanning pages")
Quoted 15 lines
mm/huge_memory.c +1 -1
index b2db98136af9..bb3b763b1829 100644
@@ -2320,7 +2320,7 @@ static void collapse_huge_page(struct mm_struct *mm,
 	pgtable_t pgtable;
 	struct page *new_page;
 	spinlock_t *pmd_ptl, *pte_ptl;
-	int isolated, result = 0;
+	int isolated = 0, result = 0;
 	unsigned long hstart, hend;
 	struct mem_cgroup *memcg;
 	unsigned long mmun_start;	/* For mmu_notifiers */
#2 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

A newly added tracepoint in the hugepage code uses a variable in the error handling that is not initialized at that point:

include/trace/events/huge_memory.h:81:230: error: 'isolated' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

The result is relatively harmless, as the trace data will in rare cases contain incorrect data.

This works around the problem by adding an explicit initialization.

Fixes 7d2eba0557c1 ("mm: add tracepoint for scanning pages")

There's the same patch in mm tree, but it got lost on the way to Linus' tree:

https://ozlabs.org/~akpm/mmots/broken-out/mm-make-optimistic-check-for-swapin-readahead-fix.patch

Andrew?

Quoted 15 lines
mm/huge_memory.c +1 -1
index b2db98136af9..bb3b763b1829 100644
@@ -2320,7 +2320,7 @@ static void collapse_huge_page(struct mm_struct *mm,
 	pgtable_t pgtable;
 	struct page *new_page;
 	spinlock_t *pmd_ptl, *pte_ptl;
-	int isolated, result = 0;
+	int isolated = 0, result = 0;
 	unsigned long hstart, hend;
 	struct mem_cgroup *memcg;
 	unsigned long mmun_start;	/* For mmu_notifiers */
Signature · 1 line
 Kirill A. Shutemov
#3 lore raw
Quoted 13 lines · Kirill A. Shutemov
Quoted 5 lines

A newly added tracepoint in the hugepage code uses a variable in the error handling that is not initialized at that point:

include/trace/events/huge_memory.h:81:230: error: 'isolated' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 7 lines

The result is relatively harmless, as the trace data will in rare cases contain incorrect data.

This works around the problem by adding an explicit initialization.

Fixes 7d2eba0557c1 ("mm: add tracepoint for scanning pages")
Quoted 7 lines

There's the same patch in mm tree, but it got lost on the way to Linus' tree:

https://ozlabs.org/~akpm/mmots/broken-out/mm-make-optimistic-check-for-swapin-readahead-fix.patch

Andrew?

Looks like the patch got the wrong title, mm-make-optimistic-check-for-swapin-readahead-fix.patch, since the subject is "khugepaged: avoid usage of uninitialized variable 'isolated'".

Anyway, feel free to add

to either patch.

Quoted 15 lines
Quoted 15 lines
mm/huge_memory.c +1 -1
index b2db98136af9..bb3b763b1829 100644
@@ -2320,7 +2320,7 @@ static void collapse_huge_page(struct mm_struct *mm,
 	pgtable_t pgtable;
 	struct page *new_page;
 	spinlock_t *pmd_ptl, *pte_ptl;
-	int isolated, result = 0;
+	int isolated = 0, result = 0;
 	unsigned long hstart, hend;
 	struct mem_cgroup *memcg;
 	unsigned long mmun_start;	/* For mmu_notifiers */