diff mbox

KVM: PPC: check for lookup_linux_ptep() returning NULL

Message ID 555DDD23.1010903@freescale.com
State New, archived
Headers show

Commit Message

Tudor Laurentiu May 21, 2015, 1:26 p.m. UTC
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.caraman@freescale.com>
Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
Cc: Scott Wood <scottwood@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(-)

Comments

Scott Wood May 21, 2015, 7:37 p.m. UTC | #1
On Thu, 2015-05-21 at 16:26 +0300, Laurentiu Tudor wrote:
> 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.caraman@freescale.com>
> Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
> Cc: Scott Wood <scottwood@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(-)

Reviewed-by: Scott Wood <scottwood@freescale.com>

-Scott


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf May 25, 2015, 9:01 p.m. UTC | #2
On 21.05.15 21:37, Scott Wood wrote:
> On Thu, 2015-05-21 at 16:26 +0300, Laurentiu Tudor wrote:
>> 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.caraman@freescale.com>
>> Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
>> Cc: Scott Wood <scottwood@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(-)
> 
> Reviewed-by: Scott Wood <scottwood@freescale.com>

Thanks, applied to kvm-ppc-queue.


Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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())