block: fix null-pointer bug on error case in block commit
commit6d759117d3fd28e38c49c56c9de206cc718d32fa
authorJeff Cody <jcody@redhat.com>
Tue, 15 Jan 2013 15:47:24 +0000 (15 10:47 -0500)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 17 Jan 2013 09:51:11 +0000 (17 10:51 +0100)
treee9e722d2b04a3685a42fda0a962a10e6ec85d1f3
parent47f4dac3fde809e3da4e60d9eb699f1d4b378249
block: fix null-pointer bug on error case in block commit

This is a bug that was caught by a coverity run by Markus.  In
the error case when we errored out to exit_restore_open early in the
function, 'overlay_bs' was still NULL at that point, although it is
used to look up flags and perform a bdrv_reopen().

Move the overlay_bs lookup to where it is needed, and check for NULL
before restoring the flags.  Also get rid of the unneeded parameter
initialization.

Reported-By: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/commit.c