提交 1e099473 编写于 作者: I Igor Mammedov 提交者: Michael S. Tsirkin

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: 4de7255f ("vhost: extend memory regions allocation to vmalloc")
Spotted-by: NDan Carpenter <dan.carpenter@oracle.com>
Suggested-by: NJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 7932c0bd
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册