qcow2: check for NULL l2meta
commit7c2bbf4aa66ca5a9fc2ca147e0e6cb6f407a3aa2
authorHu Tao <hutao@cn.fujitsu.com>
Sun, 26 Jan 2014 03:12:39 +0000 (26 11:12 +0800)
committerKevin Wolf <kwolf@redhat.com>
Sun, 9 Feb 2014 08:12:39 +0000 (9 09:12 +0100)
tree31daaf4d5aa0dd928d6da2cea12856fe7e08b511
parent33304ec9fa484e765c6249673e09e1b7d49c5b85
qcow2: check for NULL l2meta

In the case of a metadata preallocation with a large cluster size,
qcow2_alloc_cluster_offset() can allocate nothing and returns a
NULL l2meta. This patch checks for it and link2 l2 with only valid
l2meta.

Replace 9 and 512 with BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE
respectively while at the function.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c