Received: from eggs.gnu.org ([208.118.235.92]:37425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4q89-0002ko-Q4 for qemu-devel@nongnu.org; Tue, 06 Mar 2012 03:52:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4q84-0002mf-5q for qemu-devel@nongnu.org; Tue, 06 Mar 2012 03:52:25 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:35149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4q83-0002mO-Sb for qemu-devel@nongnu.org; Tue, 06 Mar 2012 03:52:20 -0500 Received: by pbcuo5 with SMTP id uo5so5524234pbc.4 for ; Tue, 06 Mar 2012 00:52:17 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 6 Mar 2012 09:52:01 +0100 Message-Id: <1331023921-32694-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1330968842-24635-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v3 10/8] use QSIMPLEQ_FOREACH_SAFE when freeing list elements List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, fsimonce@redhat.com, eblake@redhat.com, stefanha@linux.vnet.ibm.com, lcapitulino@redhat.com QSIMPLEQ_FOREACH will use the states pointer after the loop has freed it. Signed-off-by: Paolo Bonzini --- Found while (re)reviewing Jeff's patches. blockdev.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 1fb2a17..9480dbb 100644 --- a/blockdev.c +++ b/blockdev.c @@ -775,7 +775,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp) { int ret = 0; BlockdevActionList *dev_entry = dev_list; - BlkTransactionStates *states; + BlkTransactionStates *states, *next; char *new_source = NULL; QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionStates) snap_bdrv_states; @@ -926,7 +926,7 @@ delete_and_fail: } } exit: - QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) { + QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) { g_free(states); } g_free(new_source); -- 1.7.7.6