Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Igor Mammedov and committed by
Michael S. Tsirkin
1e099473 7932c0bd

+1 -4
+1 -4
drivers/vhost/vhost.c
··· 683 683 { 684 684 void *n = kzalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); 685 685 686 - if (!n) { 686 + if (!n) 687 687 n = vzalloc(size); 688 - if (!n) 689 - return ERR_PTR(-ENOMEM); 690 - } 691 688 return n; 692 689 } 693 690