From patchwork Mon Sep 20 13:11:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 65206 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 91B6EB70AB for ; Mon, 20 Sep 2010 23:12:10 +1000 (EST) Received: from localhost ([127.0.0.1]:33853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OxgAB-0006qf-1A for incoming@patchwork.ozlabs.org; Mon, 20 Sep 2010 09:12:07 -0400 Received: from [140.186.70.92] (port=39205 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oxg9a-0006pw-PL for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oxg9Y-0004yN-Kn for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:30 -0400 Received: from mtagate2.de.ibm.com ([195.212.17.162]:60754) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oxg9Y-0004xt-9V for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:28 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o8KDBRs5012646 for ; Mon, 20 Sep 2010 13:11:27 GMT Received: from d12av01.megacenter.de.ibm.com (d12av01.megacenter.de.ibm.com [9.149.165.212]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o8KDBQLQ3674362 for ; Mon, 20 Sep 2010 15:11:26 +0200 Received: from d12av01.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o8KDBQho001383 for ; Mon, 20 Sep 2010 15:11:26 +0200 Received: from stefan-thinkpad.manchester-maybrook.uk.ibm.com (dyn-9-174-219-27.manchester-maybrook.uk.ibm.com [9.174.219.27]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o8KDBPsL001372; Mon, 20 Sep 2010 15:11:26 +0200 From: Stefan Hajnoczi To: Date: Mon, 20 Sep 2010 14:11:19 +0100 Message-Id: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori , Gerd Hoffmann , Michal Suchanek , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console 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 console_select() function does not check that active_console is non-NULL before dereferencing it. When invoked with qemu -nodefaults it is possible to hit this case. This patch checks that active_console is non-NULL before stashing away the old console dimensions in console_select(). Signed-off-by: Stefan Hajnoczi Acked-by: Gerd Hoffmann Acked-by: Stefan Weil --- console.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/console.c b/console.c index 698bc10..c1728b1 100644 --- a/console.c +++ b/console.c @@ -1060,8 +1060,10 @@ void console_select(unsigned int index) if (index >= MAX_CONSOLES) return; - active_console->g_width = ds_get_width(active_console->ds); - active_console->g_height = ds_get_height(active_console->ds); + if (active_console) { + active_console->g_width = ds_get_width(active_console->ds); + active_console->g_height = ds_get_height(active_console->ds); + } s = consoles[index]; if (s) { DisplayState *ds = s->ds;