Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp724690rwi; Wed, 19 Oct 2022 02:00:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63wl2XTjusqPPcF2NsRiQUEVFS4DzUgBuPJcPlSys5/YTNKuqGyMT3GIwpDAiPqo1JkiZP X-Received: by 2002:a63:494e:0:b0:448:5163:4788 with SMTP id y14-20020a63494e000000b0044851634788mr6124694pgk.507.1666170044117; Wed, 19 Oct 2022 02:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170044; cv=none; d=google.com; s=arc-20160816; b=Mmn8mt3lz/n8K8gC1Y1cAJZBh5sSfwtYs+i2jR6t138eboAUY6mhKIP3goiBA2Efb8 MXCIsnCP5UgU8wwBZpp17OabayTb5grWTK0aUlmjonc+J1KRZXB8jYMmSMRh+t5QLrdJ suKJ9IBoArmDKHndjhBbWGy5IqXQKIcEk/4l1Vv36hBD90QrYZFZQDes2FAD9V6Hg3Hd w9phjup37hkNX01C7YXUhShZPlKDTS99jNQ7aUE/efSeE/GkA3UE9qZCwV1F7QYNRLS7 cd3C7xrc0AjHsl8HnecxQDfWHEUg8AHZPp2IyxpVVLQrCBI5oCFUVo4SuAfDVLrVnGIc czYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xk/iUI4ISzOv0vJFrYYPp8qJFmHh0U1eXBWDjeLNPMQ=; b=kwDFiQz0sridvME5ExNe0aY3E2EWtWJV9D8xA8gAjeo1iIocbXDqjvfm8p7ZfQmvXu hEB7rhjLFelJ1MBLeK8fAdfrTFxQIW/YXMPejBQV2Ek5kKIkkr+byTt+UmqL0cX8ZFRs 8Hnw3OkcB6hda9LivzHS6t1jK5mF+fFqjPOfU7Nw8AzcyR1XkCSKNiT6FPevWJeJuvwM t8GLX78xlCRXQBpVr1geZdyj1LNbidZKmYYQCVXnm2Xgw5CaxMPt640h04tR6kGwFhwr skakXQKjBXz/btt9p5GA9+nKlTSpD0JD3sfKar1IoOS85Nz8OmEnSDad9qDP3U/EbXO0 Y8Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RjVAr0Il; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056a00170200b0053e5ac66c3csi16657374pfc.38.2022.10.19.02.00.31; Wed, 19 Oct 2022 02:00:44 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RjVAr0Il; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbiJSINf (ORCPT + 99 others); Wed, 19 Oct 2022 04:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbiJSINc (ORCPT ); Wed, 19 Oct 2022 04:13:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 214407B7A4; Wed, 19 Oct 2022 01:13:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B0516B8229C; Wed, 19 Oct 2022 08:13:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE54AC433C1; Wed, 19 Oct 2022 08:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666167209; bh=grMsjd15672MfK3WGgOcqlJzZx9mIPlajFH6LUT3LyY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RjVAr0Il58bIZWLUGi0rCHF+ypPJCVywSKez1JCpU5/aREb1O+c1fsOY9WMqJTng8 6pK155IBfsEku8Mk2Sji4JfTbBKqV5//ZymA9ALU95IuYmUcT3skEtAxWW1pAMl3za crMcr8Tei9jvrqVmx7LlXij/WR1dNi0XlnPExfHhhuU1omNyFzl4Ae2CCQ8Dd5OPKO HOF+HCIy2CL4K8aXeplRwMGsEIYUOvvRzzgZbQouWWIxvKWpeVXaAbneQ86brhiXBZ 50ZM3naXT9wqbwGhu5qMyyF2JkdcdCmbFF9h0L67NdjCtUFDB6pBMivaGFKZz8ZNvJ 5ZeclOi1xCxKA== Date: Wed, 19 Oct 2022 10:13:23 +0200 From: Lorenzo Pieralisi To: Robin Murphy Cc: rafael@kernel.org, lvjianmin@loongson.cn, yangyicong@huawei.com, chenhuacai@loongson.cn, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lenb@kernel.org, jeremy.linton@arm.com Subject: Re: [PATCH] ACPI: scan: Fix DMA range assignment Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Tue, Oct 18, 2022 at 02:14:04PM +0100, 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(-) A quick comment below, otherwise: Reviewed-by: Lorenzo Pieralisi > 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; I wonder whether having a local variable to stash the base pointer would make code easier to read (so that we avoid using *map for that purpose and also to return the array to the caller). Thanks for fixing it so promptly. Lorenzo > + > 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); > -- > 2.36.1.dirty >