From patchwork Mon Feb 24 11:30:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 11400207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A6281395 for ; Mon, 24 Feb 2020 11:32:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4D6F20732 for ; Mon, 24 Feb 2020 11:32:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4D6F20732 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6Bx0-0001It-NJ; Mon, 24 Feb 2020 11:31:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6Bx0-0001Io-7h for xen-devel@lists.xenproject.org; Mon, 24 Feb 2020 11:31:02 +0000 X-Inumbo-ID: 1f278fac-56f9-11ea-8aec-12813bfff9fa Received: from huawei.com (unknown [45.249.212.191]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1f278fac-56f9-11ea-8aec-12813bfff9fa; Mon, 24 Feb 2020 11:30:57 +0000 (UTC) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C1751EBC4C7848E81306; Mon, 24 Feb 2020 19:30:54 +0800 (CST) Received: from [127.0.0.1] (10.57.101.250) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Mon, 24 Feb 2020 19:30:43 +0800 To: "xen-devel@lists.xenproject.org" From: Wei Xu Message-ID: <5E53B3E3.6070304@hisilicon.com> Date: Mon, 24 Feb 2020 19:30:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.57.101.250] X-CFilter-Loop: Reflected Subject: [Xen-devel] [PATCH] ns16550: Re-order the serial port address checking X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , "Zengtao \(B\)" , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Linuxarm , xuwei5@hisilicon.com, Shameerali Kolothum Thodi , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Check the serial port address space before checking the address. Signed-off-by: Wei Xu Reviewed-by: Jan Beulich --- xen/drivers/char/ns16550.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index dc8ac4c..425e044 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1644,6 +1644,12 @@ static int __init ns16550_acpi_uart_init(const void *data) spcr = container_of(table, struct acpi_table_spcr, header); + if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) ) + { + printk("ns16550: Address space type is not mmio\n"); + return -EINVAL; + } + /* * The serial port address may be 0 for example * if the console redirection is disabled. @@ -1654,12 +1660,6 @@ static int __init ns16550_acpi_uart_init(const void *data) return -EINVAL; } - if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) ) - { - printk("ns16550: Address space type is not mmio\n"); - return -EINVAL; - } - ns16550_init_common(uart); /*