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: 9899 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1230923E57 for ; Mon, 9 Jul 2012 14:27:15 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id C9D6FA18210 for ; Mon, 9 Jul 2012 14:27:14 +0000 (UTC) Received: by yenq6 with SMTP id q6so10817588yen.11 for ; Mon, 09 Jul 2012 07:27:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=fVZdd0Oj9liRxL2KZFyCPSV99wdIqoiQB6bnTyjd5mg=; b=I9Puea4WYmK4rc6rNY1/cPDau+LRzG78fW+8OmdBpg1bOc6sN4ev2VxVOjheIdC/0O 17hjBtseyuZxE5tjtDuao9KGLxS6vEOwe1j6S8QBC/5cIAPXbQRKW3T983R0OG8qAqJ3 eu0aH5GLpxXBQvglxYuA4vcq1e+9SkOkV4FzZ7UTh0Vdzt1o87CG6adhc+RVajyCjC5e DsAaf9WCfcD8KUyoTrwctI5IIRMcuZOxbit2hHY2CLdq3DiD40uC0qtggXNKqhk5Slwe 47u0jVZPw1Zi3SeEF/GkC9D8y7Xs3XKzygOIz4eyS7sQv8dHAb0r9n4LSrifrtO02Tbi NGpg== Received: by 10.50.160.198 with SMTP id xm6mr8713350igb.0.1341844034018; Mon, 09 Jul 2012 07:27:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp36763ibb; Mon, 9 Jul 2012 07:27:13 -0700 (PDT) Received: by 10.180.92.7 with SMTP id ci7mr34490559wib.1.1341844032468; Mon, 09 Jul 2012 07:27:12 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id n57si37883525wee.95.2012.07.09.07.27.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 07:27:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk 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 Cc: patches@linaro.org, =?UTF-8?q?Christian=20M=C3=BCller?= Subject: [PATCH] hw/pl011.c: Avoid crash on read when no chr backend present 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-Gm-Message-State: ALoCoQlTlwao+YxUxJUpZz22glgOQWrnJFQlNqlh+aL3Ixl6vfxy4RdYE7TImlUeJL0i9b8QSB49 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;