KVM: x86/mmu: Fix return value check in kvm_mmu_init_tdp_mmu()
PATCH 1/1 KVM: x86/mmu: Fix return value check in kvm_mmu_init_tdp_mmu()
If alloc_workqueue() fails, it returns NULL pointer, replaces IS_ERR() check with NULL pointer check.
Fixes 1a3320dd2939 ("KVM: MMU: propagate alloc_workqueue failure")
Reported-by Hulk Robot <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +2 -2
@@ -22,8 +22,8 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm)return 0 ; wq =alloc_workqueue ("kvm" ,WQ_UNBOUND |WQ_MEM_RECLAIM |WQ_CPU_INTENSIVE ,0 ); -if (IS_ERR (wq)) -return PTR_ERR (wq); +if (!wq) +return -ENOMEM ;/* This should not be changed for the lifetime of the VM. */ kvm->arch.tdp_mmu_enabled = true;
Signature · 1 line
2.25.1
Paolo Bonzini
maintainerQuoted 15 lines · Yang Yingliang
If
alloc_workqueue()fails, it returns NULL pointer, replacesIS_ERR()check with NULL pointer check.Fixes 1a3320dd2939 ("KVM: MMU: propagate alloc_workqueue failure")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>--- arch/x86/kvm/mmu/tdp_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kvm/mmu/tdp_mmu.c +0
-0
arch/x86/kvm/mmu/tdp_mmu.c int kvm_mmu_init_tdp_mmu(struct kvm *kvm) · line 29
Quoted 10 lines
arch/x86/kvm/mmu/tdp_mmu.c +2
-2@@ -22,8 +22,8 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm)return 0 ; wq =alloc_workqueue ("kvm" ,WQ_UNBOUND |WQ_MEM_RECLAIM |WQ_CPU_INTENSIVE ,0 ); -if (IS_ERR (wq)) -return PTR_ERR (wq); +if (!wq) +return -ENOMEM ;/* This should not be changed for the lifetime of the VM. */ kvm->arch.tdp_mmu_enabled = true;
Sent already by Dan Carpenter, thanks though!
Paolo