KVM: PPC: Fix error return code in kvm_vm_ioctl_create_spapr_tce()
Subsystems (3)
PATCH 1/1 KVM: PPC: Fix error return code in kvm_vm_ioctl_create_spapr_tce()
From: Wei Yongjun <[email protected]>
Fix to return error code -ENOMEM from the memory alloc error handling case instead of 0, as done elsewhere in this function.
--- arch/powerpc/kvm/book3s_64_vio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_vio.c +6 -2
@@ -173,8 +173,10 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, stt =kzalloc (sizeof (*stt) + npages *sizeof (struct page *),GFP_KERNEL ); -if (!stt) +if (!stt) { + ret = -ENOMEM ; goto fail; + } stt->liobn = args->liobn; stt->page_shift = args->page_shift;
@@ -184,8 +186,10 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,for (i =0 ; i < npages; i++) { stt->pages[i] =alloc_page (GFP_KERNEL | __GFP_ZERO); -if (!stt->pages[i]) +if (!stt->pages[i]) { + ret = -ENOMEM ; goto fail; + } }kvm_get_kvm (kvm);
Quoted 15 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
Fix to return error code
-ENOMEMfrom the memory alloc error handling case instead of 0, as done elsewhere in this function.Signed-off-by Wei Yongjun <[email protected]>--- arch/powerpc/kvm/book3s_64_vio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)arch/powerpc/kvm/book3s_64_vio.c +0
-0
arch/powerpc/kvm/book3s_64_vio.c long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, · line 178
Quoted 7 lines
arch/powerpc/kvm/book3s_64_vio.c +2
-1@@ -173,8 +173,10 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, stt =kzalloc (sizeof (*stt) + npages *sizeof (struct page *),GFP_KERNEL ); -if (!stt) +if (!stt) { + ret = -ENOMEM ; goto fail;
I think it would be better to set ret unconditionally to -ENOMEM before the if; that would save you one line here and make the second hunk unnecessary.
Quoted 6 lines
arch/powerpc/kvm/book3s_64_vio.c +1
-0+ } stt->liobn = args->liobn; stt->page_shift = args->page_shift;@@ -184,8 +186,10 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
arch/powerpc/kvm/book3s_64_vio.c long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, · line 195
Quoted 10 lines
arch/powerpc/kvm/book3s_64_vio.c +3
-1for (i =0 ; i < npages; i++) { stt->pages[i] =alloc_page (GFP_KERNEL | __GFP_ZERO); -if (!stt->pages[i]) +if (!stt->pages[i]) { + ret = -ENOMEM ; goto fail; + } }kvm_get_kvm (kvm);
Paul.
PATCH v2 1/1 KVM: PPC: fix error return code in kvm_vm_ioctl_create_spapr_tce()
In reply to Wei YongjunFrom: Wei Yongjun <[email protected]>
Fix to return error code -ENOMEM from the memory alloc error handling case instead of 0, as done elsewhere in this function.
--- arch/powerpc/kvm/book3s_64_vio.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_64_vio.c +1 -0
@@ -171,6 +171,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, goto fail; } + ret = -ENOMEM ; stt =kzalloc (sizeof (*stt) + npages *sizeof (struct page *),GFP_KERNEL );if (!stt)