]> git.ipfire.org Git - thirdparty/qemu.git/commit
block: Fix NULL deference for unaligned write if qiov is NULL
authorFam Zheng <famz@redhat.com>
Wed, 13 May 2015 13:12:00 +0000 (13:12 +0000)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 29 Jul 2015 23:15:27 +0000 (18:15 -0500)
commitcc883fe42ddc717b62f46118e17b45ce46dd9a11
treecba40e8c292b6c1b8dc34d5d0daa3acc31c59749
parent4072585ecfda0917837a22e317d689e4f16430af
block: Fix NULL deference for unaligned write if qiov is NULL

For zero write, callers pass in NULL qiov (qemu-io "write -z" or
scsi-disk "write same").

Commit fc3959e466 fixed bdrv_co_write_zeroes which is the common case
for this bug, but it still exists in bdrv_aio_write_zeroes. A simpler
fix would be in bdrv_co_do_pwritev which is the NULL dereference point
and covers both cases.

So don't access it in bdrv_co_do_pwritev in this case, use three aligned
writes.

[Initialize ret to 0 in bdrv_co_do_zero_pwritev() to avoid uninitialized
variable warning with gcc 4.9.2.
--Stefan]

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 1431522721-3266-3-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 9eeb6dd1b27bd57eb4e3869290e87feac8e8b226)
Conflicts:
block/io.c

* moved hunks into corresponding location in block.c due to lack of
  61007b316 in v2.3.0
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block.c