From patchwork Mon Dec 14 20:53:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 41139 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6F4E6B6F15 for ; Tue, 15 Dec 2009 08:07:16 +1100 (EST) Received: from localhost ([127.0.0.1]:51024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKI8P-0005tC-9g for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2009 16:07:13 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKHva-0002OC-5p for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKHvU-0002Jq-Uq for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:57 -0500 Received: from [199.232.76.173] (port=39720 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKHvU-0002Ja-JB for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1712) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKHvT-0002fh-Mx for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:52 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBEKroda002641 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Dec 2009 15:53:50 -0500 Received: from localhost (vpn-10-150.rdu.redhat.com [10.11.10.150]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBEKrnAL024176; Mon, 14 Dec 2009 15:53:50 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 14 Dec 2009 18:53:24 -0200 Message-Id: <1260824004-2941-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260824004-2941-1-git-send-email-lcapitulino@redhat.com> References: <1260824004-2941-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 5/5] monitor: Catch printing to non-existent monitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The monitor_vprintf() function now touches the 'mon' pointer before calling monitor_puts(), this causes block migration to segfault as its functions call monitor_printf() with a NULL 'mon'. To fix the problem this commit moves the 'mon' NULL check from monitor_puts() to monitor_vprintf(). This can potentially hide bugs, but for some reason this has been the behavior for a long time. Signed-off-by: Luiz Capitulino --- monitor.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index b518cc4..ebd0282 100644 --- a/monitor.c +++ b/monitor.c @@ -177,9 +177,6 @@ static void monitor_puts(Monitor *mon, const char *str) { char c; - if (!mon) - return; - for(;;) { c = *str++; if (c == '\0') @@ -195,6 +192,9 @@ static void monitor_puts(Monitor *mon, const char *str) void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { + if (!mon) + return; + if (mon->mc && !mon->mc->print_enabled) { qemu_error_new(QERR_UNDEFINED_ERROR); } else {