vhost: fix error handling for memory region alloc
authorIgor Mammedov <imammedo@redhat.com>
Wed, 15 Jul 2015 14:48:50 +0000 (16:48 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 27 Jul 2015 15:05:05 +0000 (18:05 +0300)
callers of vhost_kvzalloc() expect the same behaviour on
allocation error as from kmalloc/vmalloc i.e. NULL return
value. So just return vzmalloc() returned value instead of
returning ERR_PTR(-ENOMEM)

Fixes: 4de7255f7d2be5 ("vhost: extend memory regions allocation to vmalloc")

Spotted-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c

index 95bdb90fd7f06a13a99e2d37a2c97aabc4545c05..eec2f11809ff2463d2a714224925af9c679fead1 100644 (file)
@@ -683,11 +683,8 @@ static void *vhost_kvzalloc(unsigned long size)
 {
        void *n = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
 
-       if (!n) {
+       if (!n)
                n = vzalloc(size);
-               if (!n)
-                       return ERR_PTR(-ENOMEM);
-       }
        return n;
 }