KVM: PPC: Book3S HV: Check for kmalloc errors in ioctl
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 17 Mar 2017 20:41:14 +0000 (23:41 +0300)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 6 Apr 2017 05:50:43 +0000 (15:50 +1000)
kzalloc() won't actually fail because sizeof(*resize) is small, but
static checkers complain.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_64_mmu_hv.c

index 8c68145..710e491 100644 (file)
@@ -1487,6 +1487,10 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm,
        /* start new resize */
 
        resize = kzalloc(sizeof(*resize), GFP_KERNEL);
+       if (!resize) {
+               ret = -ENOMEM;
+               goto out;
+       }
        resize->order = shift;
        resize->kvm = kvm;
        INIT_WORK(&resize->work, resize_hpt_prepare_work);