virtio_blk: Fix a slient kernel panic
authorMinfei Huang <mnghuan@gmail.com>
Tue, 9 Aug 2016 08:39:20 +0000 (16:39 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 9 Aug 2016 10:42:39 +0000 (13:42 +0300)
commit347a529398e8e723338cca5d8a8ae2d9e7e93448
tree3dcf003ea2d1c35c342fbd93d9342a4014f25f2c
parent28ad55578b8a76390d966b09da8c7fa3644f5140
virtio_blk: Fix a slient kernel panic

We do a lot of memory allocation in function init_vq, and don't handle
the allocation failure properly. Then this function will return 0,
although initialization fails due to lacking memory. At that moment,
kernel will panic in guest machine, if virtio is used to drive disk.

To fix this bug, we should take care of allocation failure, and return
correct value to let caller know what happen.

Tested-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
Signed-off-by: Minfei Huang <mnghuan@gmail.com>
Signed-off-by: Minfei Huang <minfei.hmf@alibaba-inc.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/block/virtio_blk.c