Skip to contentSkip to conversation

pte_alloc_kernel needs additional check

PATCH In review Paul Larson 3 participants 3 messages Feb 24, 2003

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

PATCH 1/1 pte_alloc_kernel needs additional check

This applies against 2.5.63.
pte_alloc_kernel needs a check for pmd_present(*pmd) at the end.

Thanks,
Paul Larson

mm/memory.c +3 -1
@@ -186,7 +186,9 @@
 		pmd_populate_kernel(mm, pmd, new);
 	}
 out:
-	return pte_offset_kernel(pmd, address);
+	if (pmd_present(*pmd))
+		return pte_offset_kernel(pmd, address);
+	return NULL;
 }
 #define PTE_TABLE_MASK	((PTRS_PER_PTE-1) * sizeof(pte_t))
 #define PMD_TABLE_MASK	((PTRS_PER_PMD-1) * sizeof(pmd_t))
#1 lore raw
Quoted 10 lines · Paul Larson

This applies against 2.5.63.
pte_alloc_kernel needs a check for pmd_present(*pmd) at the end.

Thanks,
Paul Larson

mm/memory.c line 194

Quoted 10 lines
mm/memory.c +3 -1
@@ -186,7 +186,9 @@
 		pmd_populate_kernel(mm, pmd, new);
 	}
 out:
-	return pte_offset_kernel(pmd, address);
+	if (pmd_present(*pmd))
+		return pte_offset_kernel(pmd, address);
+	return NULL;
 }
 #define PTE_TABLE_MASK	((PTRS_PER_PTE-1) * sizeof(pte_t))
 #define PMD_TABLE_MASK	((PTRS_PER_PMD-1) * sizeof(pmd_t))

Confused. I cannot see a codepath which makes this test necessary?

#2 lore raw

Paul Larson <[email protected]> wrote:
- return pte_offset_kernel(pmd, address);
+ if (pmd_present(*pmd))
+ return pte_offset_kernel(pmd, address);
+ return NULL;

Quoted 1 line · Andrew Morton

Confused. I cannot see a codepath which makes this test necessary?

Looks like it's OOM handling by analogy with pte_alloc_map().

-- wli