From patchwork Mon Jul 9 14:27:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 169859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 38B7C2C02BC for ; Tue, 10 Jul 2012 00:27:33 +1000 (EST) Received: from localhost ([::1]:39107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoEvz-00075e-2M for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 10:27:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoEvo-000744-1r for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:27:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoEvh-0003sg-Ba for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:27:19 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:35000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoEvh-0003s1-4Z for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:27:13 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1SoEve-0007VS-0K; Mon, 09 Jul 2012 15:27:10 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 9 Jul 2012 15:27:09 +0100 Message-Id: <1341844029-28831-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: =?UTF-8?q?Christian=20M=C3=BCller?= , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/pl011.c: Avoid crash on read when no chr backend present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a missing guard that meant we would segfault if the guest read UARTDR on a PL011 serial device which had no chr backend connected. (This didn't happen for Linux guests because Linux reads the flags register and doesn't try to read the UART if it's empty.) Reported-by: Christian Müller Signed-off-by: Peter Maydell --- hw/pl011.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/pl011.c b/hw/pl011.c index 8a5a8f5..3245702 100644 --- a/hw/pl011.c +++ b/hw/pl011.c @@ -78,7 +78,9 @@ static uint64_t pl011_read(void *opaque, target_phys_addr_t offset, if (s->read_count == s->read_trigger - 1) s->int_level &= ~ PL011_INT_RX; pl011_update(s); - qemu_chr_accept_input(s->chr); + if (s->chr) { + qemu_chr_accept_input(s->chr); + } return c; case 1: /* UARTCR */ return 0;