Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp675075qtb; Wed, 19 Oct 2022 11:52:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mxFmlz/4kHmu2FT8pQc10joJ3r2gHa0J6vABBEl4GlHsHZ5SVMYqsViZtr8MG7/3B9+VW X-Received: by 2002:a05:6402:5211:b0:45d:131b:8dd7 with SMTP id s17-20020a056402521100b0045d131b8dd7mr8924909edd.93.1666205529710; Wed, 19 Oct 2022 11:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666205529; cv=none; d=google.com; s=arc-20160816; b=laMM7FqhvWPqBiwRSBDXhbXAcD0U6Btcr1K4zTBHx70QPtryNqn+CoUmNMhlo9F9vl dMsl3nqS2FXOrHdaD69Mmj3403MAkpL5Qaou7nXut88qxeBnaZuH/NCMIdS4t+whPGQ+ sLCqm2XWZYm7b2m/8eRayOZkLD769D5fabLU8sfgyhsMcLYutx/AW6ECY1cGrcDd6NYS ipQyaYgZ9ozeKcuSZpRA8Trqlr8kiI+JXsaFpMAofhQUi6AYcRco4lJWzH9dcj55jplY LDEflJlJy8F+nVzq9TF+BJZGquIdk3WtpvA3CVxN0T7e2DsQTtyLmr1gOqfLWNXDYKhh Dnew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=ksoUwNbFYLLNy8hgo3QVu6DMpU3MXF6PNRL2jmsEX/w=; b=zLsMjVeGoVEF+3O6yyBwQJpZpN+4yZphg2G1Ne4vr7d+SEnifRalmrBvBLDV+6xAAg 0h7HOGAEAT+4BHM4/OCuXLmQWqUf65GuJSEaydOYjwkSIOiwIGJ5qqhKSU9FATzZtZE+ FH/yXwzj6He5tWMiHBgxiyu9JEE7LrdXbJV3ccvpm53dJ3ITJwP+tfd/E2Nk+C892jv/ Vu862AG383Utf7tWtYNp8Jl5dtBMWFHmx+s/YdUc4sltJkKxu6tNL1Kuhft2MrBq6WWS xjzK1MRBCGaBD0K1A2FQ79UU9HPkYkjOm0F2bzgO0pfGewP3XdlDe47UE8VTQ5fSEpjI 5Y1w== 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=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 w7-20020a05640234c700b0045cfa0b1f46si16815237edc.11.2022.10.19.11.51.18; Wed, 19 Oct 2022 11:52:09 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbiJSSan (ORCPT + 99 others); Wed, 19 Oct 2022 14:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbiJSSak (ORCPT ); Wed, 19 Oct 2022 14:30:40 -0400 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776C711702B; Wed, 19 Oct 2022 11:30:39 -0700 (PDT) Received: by mail-qk1-f171.google.com with SMTP id o22so11293297qkl.8; Wed, 19 Oct 2022 11:30:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ksoUwNbFYLLNy8hgo3QVu6DMpU3MXF6PNRL2jmsEX/w=; b=lQC7ixmJ9+XsTgDun3JmYo7/PQrIbLM4EwNCxnnifawsVuLBSih5FkND6HaBPhNpbs uPlArpoMDI7Vz+WLAJRVBbSDsI6R7axptdanBRoerQYhijnI9Q0nEPlA4pNmgT+cEAAS fdr59BQVHTAAhicoh3JsWKH/RiTWuViQMdTmSCoxhqSapksCV2BM0PE0yFl/8Av/kDIk MJ1NbFnz0mrpZjZR0GNtBOj1aP3cVuer6vJNjeQCEYeys+YH+LUXX47MdVhpQxw7paRO VuaXBoGUYOEA0yTAHZpAJSkAyfWa7FDidGGxiH3RPXMLZTrKPTZbh2lcngo9Yip5tQub piHw== X-Gm-Message-State: ACrzQf19jio5F4fbZaqD3bbyPrxE8I86+Sf5KyuXZW1WbUy/m2c3gXJf JYaBLlwupLD200vawQvZTMFaSKdJuXl4U3YrmgcTJNC+ X-Received: by 2002:a05:620a:158f:b0:6ee:93d5:e249 with SMTP id d15-20020a05620a158f00b006ee93d5e249mr6577755qkk.505.1666204238591; Wed, 19 Oct 2022 11:30:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 19 Oct 2022 20:30:27 +0200 Message-ID: Subject: Re: [PATCH] ACPI: scan: Fix DMA range assignment To: Lorenzo Pieralisi , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Wed, Oct 19, 2022 at 10:13 AM Lorenzo Pieralisi wrote: > > 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 Applied as is and the code may be cleaned up later. Thanks! > > 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 > >