From patchwork Thu Aug 13 10:44:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 52376 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 03AB422EC6 for ; Thu, 13 Aug 2015 11:02:26 +0000 (UTC) Received: by labia3 with SMTP id ia3sf15639583lab.1 for ; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=m19AksbzVtTUyxzxc9W7xxgwd+b7LNu4tOR8m5G6KNg=; b=jt/m6P6NwgOSTOwu4FEf0cmGJooNt8j6KAm32V0U87j2D2asEpIyV++05DEbUuGxUI xphBHa6LkDUnmimOaVMe5LL/xn+HncYTHEPXRidHjZN8lXy3qkSVQzFyW+CPMK1Tqsm/ nOiqhqTEwi2Cq7YHOjnT/5a14MNCUeHzJzyWlgzsnHFagTz4+UPVqmL9R2u6za9vpDn0 m6gdF75FadLDpt/jPZxi9WDkfYTtSo+N/twjIuuewLqSNUx2NpJQ60oXpgkkhV+wmWs1 BpVJyrvqYhJBuOp5R5nH3AR3OLvXSjlqWIixT475yN+YwVhhUO0p6AS+qeEExAVXyZEA 74+A== X-Gm-Message-State: ALoCoQkNMVo+HohB3u1LqwQ+51i+slYgOSl3sxxYhq3dpqVkKFMygZV1ey1OpzYiex/yHrpwpBzG X-Received: by 10.180.96.226 with SMTP id dv2mr248044wib.2.1439463744739; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.234 with SMTP id w10ls164809lag.41.gmail; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) X-Received: by 10.152.179.170 with SMTP id dh10mr18224382lac.22.1439463744567; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id n14si1842380laa.83.2015.08.13.04.02.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 04:02:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbpu9 with SMTP id pu9so24906064lbb.3 for ; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr36161125lal.35.1439463744478; Thu, 13 Aug 2015 04:02:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp864766lba; Thu, 13 Aug 2015 04:02:23 -0700 (PDT) X-Received: by 10.50.128.169 with SMTP id np9mr29270956igb.37.1439463742715; Thu, 13 Aug 2015 04:02:22 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id z9si1212889igw.33.2015.08.13.04.02.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Aug 2015 04:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:41782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPqH7-0002Dq-H3 for patch@linaro.org; Thu, 13 Aug 2015 07:02:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0N-0005Qt-Gk for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPq0L-0005O4-Np for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:03 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0L-0005DT-Br for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:01 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZPq08-00072J-GQ for qemu-devel@nongnu.org; Thu, 13 Aug 2015 11:44:48 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Aug 2015 11:44:47 +0100 Message-Id: <1439462687-26903-28-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1439462687-26903-1-git-send-email-peter.maydell@linaro.org> References: <1439462687-26903-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 Subject: [Qemu-devel] [PULL 27/27] i.MX: Fix UART driver to work with unitialized "chardev" device 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Jean-Christophe Dubois The "chardev" property initialization might have failed (for example because there are not enough chardevs provided by QEMU). The serial device emulator needs to be able to work with an uninitialized (NULL) chardev device pointer. This patch adds some missing tests on the chr pointer value before using it. Signed-off-by: Jean-Christophe Dubois Reviewed-by: Peter Crosthwaite Message-id: 1438342461-18967-1-git-send-email-jcd@tribudubois.net Signed-off-by: Peter Maydell --- hw/char/imx_serial.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index f9da59f..801156d 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -125,7 +125,9 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset, s->usr2 &= ~USR2_RDR; s->uts1 |= UTS1_RXEMPTY; imx_update(s); - qemu_chr_accept_input(s->chr); + if (s->chr) { + qemu_chr_accept_input(s->chr); + } } return c; @@ -212,7 +214,9 @@ static void imx_serial_write(void *opaque, hwaddr offset, } if (value & UCR2_RXEN) { if (!(s->ucr2 & UCR2_RXEN)) { - qemu_chr_accept_input(s->chr); + if (s->chr) { + qemu_chr_accept_input(s->chr); + } } } s->ucr2 = value & 0xffff;