From patchwork Mon Jul 15 16:01:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 259105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D1C442C013F for ; Tue, 16 Jul 2013 02:03:29 +1000 (EST) Received: from localhost ([::1]:41759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UylFH-0002zc-A0 for incoming@patchwork.ozlabs.org; Mon, 15 Jul 2013 12:03:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UylDh-0000kq-NG for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UylDd-0005fN-67 for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:01:49 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:58608 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UylDc-0005dd-Vz for qemu-devel@nongnu.org; Mon, 15 Jul 2013 12:01:45 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1UylDT-0007BY-Di; Mon, 15 Jul 2013 17:01:35 +0100 From: Peter Maydell To: Anthony Liguori Date: Mon, 15 Jul 2013 17:01:29 +0100 Message-Id: <1373904095-27592-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373904095-27592-1-git-send-email-peter.maydell@linaro.org> References: <1373904095-27592-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: qemu-devel@nongnu.org, Paul Brook Subject: [Qemu-devel] [PULL 1/7] char/cadence_uart: Fix reset for unattached instances 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 From: Peter Crosthwaite commit 1db8b5efe0c2b5000e50691eea61264a615f43de introduced an issue where QEMU would segfault if you have an unattached Cadence UART. Fix by guarding the flush-on-reset logic on there being a qemu_chr attachment. Reported-by: Soren Brinkmann Signed-off-by: Peter Crosthwaite Tested-by: Soren Brinkmann Message-id: 9009578ee10a50d994b2e10aa2840d73765f5968.1370577272.git.peter.crosthwaite@xilinx.com Signed-off-by: Peter Maydell --- hw/char/cadence_uart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 131370a..4d457f8 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -157,7 +157,9 @@ static void uart_rx_reset(UartState *s) { s->rx_wpos = 0; s->rx_count = 0; - qemu_chr_accept_input(s->chr); + if (s->chr) { + qemu_chr_accept_input(s->chr); + } s->r[R_SR] |= UART_SR_INTR_REMPTY; s->r[R_SR] &= ~UART_SR_INTR_RFUL;