Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp386631rwi; Tue, 18 Oct 2022 19:44:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7R8lzB1rjdACfDgS5OcxsbySJmIbDV3RsoUqiIaQ+siDGsTaL7pqwv3TdAGu770P1hp8pu X-Received: by 2002:a17:907:7e95:b0:78d:e9cf:82c7 with SMTP id qb21-20020a1709077e9500b0078de9cf82c7mr4934307ejc.724.1666147457498; Tue, 18 Oct 2022 19:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666147457; cv=none; d=google.com; s=arc-20160816; b=FBbLl/qRFqcMysPAeLa9nbyIve0kuernF+dtk33YekGVZhb2KTuV3GexlaZo+41v54 evfOnBDoTxAHsBUZi08SzODzutV1iSC8ucbQOH+/VuHdVvVSjWWSmZFLxOmvWJsbNC0e f9csCAD6y03rmrv/yp28HSOgdzNb5vj8ARfamFZ2FykrHA3R3Spxy+mQoiyEJCcznH/Q b56WSqC0ISh+u9Ave0rpOhRNNn0JlBR/OdAm6e3X12Pi0a7n46epE9mFSBO+e8JmWgb/ 8qyvRYX2mhu3EPIplgNXudyjiqOptPRqhV8qbIllJYqlxwl4swVDnKAQm0tROdzGJYzO l00A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=CdH//aTNdLGJLVAtXG99vbZeHrPmGR51CEWXrZabmZg=; b=YDd7MszxjKS5exZ8Y45g2Mg+6ZlhP4traUFB0S3bjneed6K92+HnC5+feNg5Nt3lst qkf4VfR1J2ExjYaU4z2Xqh7rh9XKXmgWSWwGYGaUSI6lp/4t1uINYJ3mNgtrj0x1bpjd xiORW+5js0IXNNk1reC5WB/dZ9PgnkCqXIp7LAQMX3FOH8Jl5nFlCnSCv+uAo9X7h96W ne3D+TqHaMiYZ3sFKn+p7rTtzSC8XhhsMfhGT56uRWvNGiwcr03C/sl7+EA3l2/k68vV nTy+pDJN9c2LjR5jPxHM4G/PyKG+ctJ1G7KJ9fxFu21Y5DHxffldHpvYXOq0gJr98Xkq e3dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a05640234c300b004595a90c510si16897832edc.3.2022.10.18.19.43.52; Tue, 18 Oct 2022 19:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbiJSCHj (ORCPT + 99 others); Tue, 18 Oct 2022 22:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiJSCHh (ORCPT ); Tue, 18 Oct 2022 22:07:37 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735D16C77B; Tue, 18 Oct 2022 19:07:36 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MsYvq0JBGzJn3c; Wed, 19 Oct 2022 10:04:55 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 10:07:33 +0800 CC: , , , , , , , Subject: Re: [PATCH] ACPI: scan: Fix DMA range assignment To: Robin Murphy , References: From: Yicong Yang Message-ID: <05cb83dd-76e8-d12c-957e-90fe930d03de@huawei.com> Date: Wed, 19 Oct 2022 10:07:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/10/18 21:14, Robin Murphy wrote: > Assigning the device's dma_range_map from the iterator variable after > the loop means it always points to the empty terminator at the end of > the map, which is not what we want. Similarly, freeing the iterator on > error when it points to somwhere in the middle of the allocated array > won't work either. Fix this. > > Fixes: bf2ee8d0c385 ("ACPI: scan: Support multiple DMA windows with different offsets") Thanks for fixing this. Works on my platform. Tested-by: Yicong Yang > Signed-off-by: Robin Murphy > --- > drivers/acpi/scan.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 558664d169fc..024cc373a197 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -1509,9 +1509,12 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map) > goto out; > } > > + *map = r; > + > list_for_each_entry(rentry, &list, node) { > if (rentry->res->start >= rentry->res->end) { > - kfree(r); > + kfree(*map); > + *map = NULL; > ret = -EINVAL; > dev_dbg(dma_dev, "Invalid DMA regions configuration\n"); > goto out; > @@ -1523,8 +1526,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map) > r->offset = rentry->offset; > r++; > } > - > - *map = r; > } > out: > acpi_dev_free_resource_list(&list); >