From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbdb-0003nm-SN for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:22:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLbda-0000zq-HK for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:22:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49828 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLbda-0000zD-B4 for qemu-devel@nongnu.org; Tue, 09 Oct 2012 11:22:26 -0400 From: Tim Hardeck Date: Tue, 9 Oct 2012 17:21:41 +0200 Message-Id: <1349796101-6660-3-git-send-email-thardeck@suse.de> In-Reply-To: <1349796101-6660-1-git-send-email-thardeck@suse.de> References: <1349796101-6660-1-git-send-email-thardeck@suse.de> Subject: [Qemu-devel] [PATCH 2/2] qemu queue: fix uninitialized removals List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Tim Hardeck , aliguori@us.ibm.com When calling QTAILQ_REMOVE or QLIST_REMOVE on an unitialized list QEMU segfaults. Check for this case specifically on item removal. Signed-off-by: Tim Hardeck --- qemu-queue.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qemu-queue.h b/qemu-queue.h index 9288cd8..47ed239 100644 --- a/qemu-queue.h +++ b/qemu-queue.h @@ -141,7 +141,9 @@ struct { \ if ((elm)->field.le_next != NULL) \ (elm)->field.le_next->field.le_prev = \ (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ + if ((elm)->field.le_prev != NULL) { \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + } \ } while (/*CONSTCOND*/0) #define QLIST_FOREACH(var, head, field) \ @@ -381,7 +383,9 @@ struct { \ (elm)->field.tqe_prev; \ else \ (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + if ((elm)->field.tqe_prev != NULL) { \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + } \ } while (/*CONSTCOND*/0) #define QTAILQ_FOREACH(var, head, field) \ -- 1.7.10.4