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: 183763 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp274770ile; Mon, 24 Feb 2020 03:32:22 -0800 (PST) X-Google-Smtp-Source: APXvYqylg7+bDf2dupudm8/lE4bLclbPhSqqi3n+EtFnRaIC14iEwEPL6I5zG63y/gRn0w/J1vLZ X-Received: by 2002:a05:6638:2b6:: with SMTP id d22mr51238075jaq.59.1582543942139; Mon, 24 Feb 2020 03:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582543942; cv=none; d=google.com; s=arc-20160816; b=fj4EFiR738ouH+tZIh3IoSe73xcILm8JXb1eJ3KxmAy7VMx7YaVgAVolompSicA6pj Dmbd49226s7CBtHhxvyoBA+6Xa/on/qLttg3KeYNcy61mI8lYihtzO2OuEwqepQdgHxE blSob7aEAVLKiAUchqk5upY7OCsMqHclpGHYvhYAdMdtblCF1aptVLjqZauuJFRvt48m 6+uP6gFMvvrs8VUqTA5T9LzRF78sC+ACnMod36qN7R3sf1S7rbjt3+C0bLQGfm5vE16R fByuQ6IRV03bhQ3vteCl4s1brn6eeEerlmul79wyjhkqyrJRAkJyXtxuY4TPvuNwEALP WJiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:date:message-id:from:to; bh=nq/KAy6KHV0R+7jrld8ZQnrg9Oa8j7UPH6diPSA14vY=; b=MCrhVQfZkQ0U5nqTWXCKIytx798oKy3NLFYeD7A5OdUKTvVhFk1CpkJ2l/bRC6BXrY q4hRSWK6+PAo9Bc8ezQ+woJCa6KS4vI1HsqMFPtVFY0FWs9QFKSn2+SC3Z9gWEKZRkkO ++fkK8XfykinCRwAykvKV/pJ45sTQmGfYngtSJvrYqthUAY2UDuqRUMStuF31J8HyOD4 MCNLj3G0Plnpyw+hgX0IaOdZhIolKWDXP95g5Krul7ux+g9KmkGDXN61djFGujWmT4Tj 8wUwRv0ZXZuSpmgTkO0aowjQPCDp5rw2QS5e8w9J0qO8G4Kdzc9skpKtfjg/dx+YfrBc IDKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id g21si8611535jao.100.2020.02.24.03.32.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Feb 2020 03:32:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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); /*