x86: cpa: clean up change_page_attr_set/clear()
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 5cfc0d4..145f5ed 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -312,10 +312,10 @@
for (i = 0; i < numpages ; i++) {
pte = lookup_address(addr, &level);
- if (pte)
- current_prot = pte_pgprot(*pte);
- else
- pgprot_val(current_prot) = 0;
+ if (!pte)
+ return -EINVAL;
+
+ current_prot = pte_pgprot(*pte);
pgprot_val(new_prot) =
pgprot_val(current_prot) | pgprot_val(prot);
@@ -356,11 +356,12 @@
int i, ret;
for (i = 0; i < numpages; i++) {
+
pte = lookup_address(addr, &level);
- if (pte)
- current_prot = pte_pgprot(*pte);
- else
- pgprot_val(current_prot) = 0;
+ if (!pte)
+ return -EINVAL;
+
+ current_prot = pte_pgprot(*pte);
pgprot_val(new_prot) =
pgprot_val(current_prot) & ~pgprot_val(prot);