Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6014795rwi; Tue, 18 Oct 2022 07:08:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5HF1IbYtt6W+bqh9rAhEDJFl29IGTlXQN24/O/Jr8FcvEOwiy7N57wPyda8yZpMrVUgfjK X-Received: by 2002:a17:903:41c3:b0:17f:8def:dc92 with SMTP id u3-20020a17090341c300b0017f8defdc92mr3224595ple.7.1666102126806; Tue, 18 Oct 2022 07:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666102126; cv=none; d=google.com; s=arc-20160816; b=D7+wlndhQgw1PMvrl1b2S0CMJBG4Sh+IHXS0p3N0T3pB5W2ZxFfq6OwkM1IWvgs/ZY /fEDHP8wR8LwvNxNbooJIuEicdXGtA6vmfzPqR4DjKcCsHBzNu1SwvxGBqvmTPO3xgd4 alIeZc/1eeMADiNR6tjW5kiofZ8sDSQfwASy1nMrxN2+sZz4Mae/8vGl066R2vMgnBHZ FMkuO9wKdPqSSPD9WVYa507v2uKxr2D+7HTLzXJYOVwLQgR0ZU8TchXszeDujMa0KTFg INymcT2z88tvNuiI1bBqXKUBQ+M+WlnklVGTQjlfyDO5r/+YFTrQrdymFyZ5ZRInK9Qc WVuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=gaWsEvyRGKujXfOYZPKhMqUebvm7QpOPiE9FYmJhn7Q=; b=qF2XzAcfFHGqi64FXcLidkknvbjT2I4PY7VWWgj6zFUAamKaD0edeDcYUopTOvWXUu Lji/in/5Ia9cPcbA5ZQKHUDNjuZI07rleVuh+TPdG6GPXadwQ12z2FUHieqf/X7hKqDJ kJSCJ6D+tdpiKNjEKJxzGuaZ24xLIxsrfoKhxViUyKgMT/jKGEBhSfz8qQxmzuLlZnJw 426bvuQnpSqdambDsQFSB1r+exq//8brZM4PIYLm99Q3RHmflZYXA+z2z31yOJ3Lw5j3 9DMuz8/nV+IIoNf9JXBKKhLjnnqzgV2QUYANkdTWoNiMFrtXRU6yUZdfBAwJdqMluTsH R7mA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902b68600b00174418919a6si14327379pls.513.2022.10.18.07.08.07; Tue, 18 Oct 2022 07:08:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbiJRNbZ (ORCPT + 99 others); Tue, 18 Oct 2022 09:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbiJRNbX (ORCPT ); Tue, 18 Oct 2022 09:31:23 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11647C90F1; Tue, 18 Oct 2022 06:31:20 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.32]) by gateway (Coremail) with SMTP id _____8Dxu9ilqk5jE3AAAA--.2541S3; Tue, 18 Oct 2022 21:31:17 +0800 (CST) Received: from [10.20.42.32] (unknown [10.20.42.32]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxLeCkqk5jpbcAAA--.2979S3; Tue, 18 Oct 2022 21:31:17 +0800 (CST) Subject: Re: [PATCH] ACPI: scan: Fix DMA range assignment To: Robin Murphy , rafael@kernel.org Cc: yangyicong@huawei.com, lpieralisi@kernel.org, chenhuacai@loongson.cn, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lenb@kernel.org, jeremy.linton@arm.com References: From: Jianmin Lv Message-ID: <3793c2e8-15ad-2628-0660-f04d4f1071fd@loongson.cn> Date: Tue, 18 Oct 2022 21:31:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8DxLeCkqk5jpbcAAA--.2979S3 X-CM-SenderInfo: 5oymxthqpl0qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7tr4DKrWDWr4Utr1ruFyUZFb_yoW8Gw4fp3 yYg34UCr4xJrs5Wr1xJws3ua1Y9395WrW8urW5C3sa93ZxGF90yrWrCry5u3Z3JF95JF4x ZFnI9F18CFWUJrDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bI8YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l42 xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWU GwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI4 8JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4U MIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I 8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUcVc_UUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_PASS,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 Seems good. Thanks very much. Reviewed-by: Jianmin Lv On 2022/10/18 下午9: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") > 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); >