diff options
author | Igor Mammedov <imammedo@redhat.com> | 2015-07-15 10:48:50 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-07-27 11:05:05 -0400 |
commit | 1e0994730f772580ff98754eb5595190cdf371ef (patch) | |
tree | 1db1d0a687ebb0f980d9083ba65d9e447faafab0 | |
parent | 7932c0bd7740f4cd2aa168d3ce0199e7af7d72d5 (diff) |
vhost: fix error handling for memory region alloc
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>
-rw-r--r-- | drivers/vhost/vhost.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 95bdb90fd7f0..eec2f11809ff 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -683,11 +683,8 @@ static void *vhost_kvzalloc(unsigned long size) | |||
683 | { | 683 | { |
684 | void *n = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); | 684 | void *n = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); |
685 | 685 | ||
686 | if (!n) { | 686 | if (!n) |
687 | n = vzalloc(size); | 687 | n = vzalloc(size); |
688 | if (!n) | ||
689 | return ERR_PTR(-ENOMEM); | ||
690 | } | ||
691 | return n; | 688 | return n; |
692 | } | 689 | } |
693 | 690 | ||