Skip to content

Commit ba2b228

Browse files
cspiegel-cypherpathstefanhaRH
authored andcommitted
snapshot: Reset err to NULL to avoid double free
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. Broken in commit a89d89d. Signed-off-by: Chris Spiegel <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 54a7f8f commit ba2b228

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

savevm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ int load_vmstate(const char *name)
12461246
void do_delvm(Monitor *mon, const QDict *qdict)
12471247
{
12481248
BlockDriverState *bs;
1249-
Error *err = NULL;
1249+
Error *err;
12501250
const char *name = qdict_get_str(qdict, "name");
12511251

12521252
if (!find_vmstate_bs()) {
@@ -1257,6 +1257,7 @@ void do_delvm(Monitor *mon, const QDict *qdict)
12571257
bs = NULL;
12581258
while ((bs = bdrv_next(bs))) {
12591259
if (bdrv_can_snapshot(bs)) {
1260+
err = NULL;
12601261
bdrv_snapshot_delete_by_id_or_name(bs, name, &err);
12611262
if (err) {
12621263
monitor_printf(mon,

0 commit comments

Comments
 (0)