Received: from eggs.gnu.org ([2001:4830:134:3::10]:59138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbBpp-0007cX-3M for qemu-devel@nongnu.org; Mon, 06 Oct 2014 13:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbBpk-0006Cp-0x for qemu-devel@nongnu.org; Mon, 06 Oct 2014 13:12:33 -0400 Received: from 68-113-0-218.static.knwc.wa.charter.com ([68.113.0.218]:47610 helo=chris.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbBpj-0006Ci-QD for qemu-devel@nongnu.org; Mon, 06 Oct 2014 13:12:27 -0400 From: Chris Spiegel Date: Mon, 6 Oct 2014 09:33:45 -0700 Message-Id: <1412613225-32676-1-git-send-email-chris.spiegel@cypherpath.com> Subject: [Qemu-devel] [PATCH] snapshot: Reset err to NULL to avoid double free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Chris Spiegel If an error occurs in bdrv_snapshot_delete_by_id_or_name(), "err" is freed. If "err" is not set to NULL before calling bdrv_snapshot_delete_by_id_or_name() again, it will not be updated on error, and will be freed again. This can be triggered by starting a VM with at least two drives and then attempting to delete a non-existent snapshot. Signed-off-by: Chris Spiegel --- savevm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/savevm.c b/savevm.c index 2d8eb96..08ec678 100644 --- a/savevm.c +++ b/savevm.c @@ -1246,7 +1246,7 @@ int load_vmstate(const char *name) void do_delvm(Monitor *mon, const QDict *qdict) { BlockDriverState *bs; - Error *err = NULL; + Error *err; const char *name = qdict_get_str(qdict, "name"); if (!find_vmstate_bs()) { @@ -1257,6 +1257,7 @@ void do_delvm(Monitor *mon, const QDict *qdict) bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs)) { + err = NULL; bdrv_snapshot_delete_by_id_or_name(bs, name, &err); if (err) { monitor_printf(mon, -- 2.1.2