If passed a larger page size lookup_linux_ptep()
may fail, so add a check for that and bail out
if that's the case.
This was found with the help of a static
code analysis tool.

Signed-off-by: Mihai Caraman <mihai.cara...@freescale.com>
Signed-off-by: Laurentiu Tudor <laurentiu.tu...@freescale.com>
Cc: Scott Wood <scottw...@freescale.com>
---
based on https://github.com/agraf/linux-2.6.git kvm-ppc-next

 arch/powerpc/kvm/e500_mmu_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index cc536d4..249c816 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -469,7 +469,7 @@ static inline int kvmppc_e500_shadow_map(struct 
kvmppc_vcpu_e500 *vcpu_e500,
 
        pgdir = vcpu_e500->vcpu.arch.pgdir;
        ptep = lookup_linux_ptep(pgdir, hva, &tsize_pages);
-       if (pte_present(*ptep))
+       if (ptep && pte_present(*ptep))
                wimg = (*ptep >> PTE_WIMGE_SHIFT) & MAS2_WIMGE_MASK;
        else {
                if (printk_ratelimit())
-- 
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to