Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp391984lqm; Wed, 1 May 2024 04:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVO702tssMeihJBnnLtsip6kefmsagunaU5iLE2sRv//0/2RcyQKnEs8nsW86rcAyjlyrjWjpSCaLim/jLCz3I9xqfoNlVDmT+u6nVXNA== X-Google-Smtp-Source: AGHT+IHUbqU+XAGQoutdg5QscqaAyOTddpfv12Kwdm/bBf6JugXyrvYeNcNmgTVp9gJMos8fzzIi X-Received: by 2002:a05:6a21:8888:b0:1a7:9afe:2f48 with SMTP id tb8-20020a056a21888800b001a79afe2f48mr2761814pzc.27.1714561743200; Wed, 01 May 2024 04:09:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714561743; cv=pass; d=google.com; s=arc-20160816; b=BR/tEVWqq4pGSvg2/el9iKQjOfghO6yWZsJVBqZzKtLEmQv7XR3o68eofSDgi/hROc Mwx9r1CJJpnRHh/1uZ5tCCWzaZd2yG6rkDkcPRN9IBjMD9I5AZSHjBB/Db5B/tT7Qn0M ChzZOfA36QfMwHoPf79r2vmfIsXVIk9hKkwTDoikADOYmo7UrGF7DObJ46qvW/zldvGg I1FGwJsGw4Pj1XTUsajJ0RC/FDUnIImgII4HBxPjJ/hvo7KTYjOWqkeSHPw7S6NhCgUn lSQ6IRkD50/AqEZ+pLv4ZgKubELLJZahKNaD4yz9ifaT7DdR1UPqDMAZi3AXinPuUMeN Ds1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=zKF5Ja8RF/oNJT4TC1IfFD14KbZ4Wk/Bwwx0tmogQXQ=; fh=nrF9AF5V0JZ98ZvQAkRbGec7b0P5qwIhQGOpyP1Jjzw=; b=GA+yVhiPoQ9d2ALRoUFGEmU+7Fi6gf46IvkrbD3bdnjZthC54vadYgnbfanqqJl7CX rB1agSLbv3RCGJhoi8HUo6eJGcnG5LcQFhhbswKvfOG82ImmGDxT9TDeX/+6cwNr8G0Q RKhteseyCaNgTfriNLciBDhOFgbIHyqCF0vhHa3eYYPgDzS3vvWj0TyLYeYumchhpBR7 5oKDOXg9Y+xHDU4qguhdt3okgtptmYX1e73an6t/U28Y5+n20CGDZ/55ijrJ65MAf+lQ 9Hqbym2oD50buJOSWlclMrCaY4BjtKEgyht4eH30qcLcjOLCzsCnIFPgyyUQE3QYXEHa 9pHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m11-20020a63580b000000b005e84e71d9b6si24311017pgb.93.2024.05.01.04.09.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 04:09:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B10F1B22F51 for ; Wed, 1 May 2024 11:08:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAA9456770; Wed, 1 May 2024 11:08:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E522E5644B for ; Wed, 1 May 2024 11:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561732; cv=none; b=cxXFkpidzK+f5opra8mUCKuYi9nDDzcock+l5wTvnZlgdLNmlxYznD4rPDNanvZlJNOvxoSJZbMPS66e+jtzVTB75dPAxcAJ7pJzfvFDP2BepTqfGVfz63LC4qu7x5T3nSyiaW8BQNKNcccrfGfYU8+vI5SsuMvWdnC+JKOEN3c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561732; c=relaxed/simple; bh=DTXkuYlm1URgdAGDGl/LZ8PwWXFanxNREFGd7yquhR8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=V8hnvMiZxvi+jqv6iYJojnfx1QuKrcp+SQ8x4lWUOJhKe0f+on/a/GmOLbU56CSb5BZwZPgsRNT4NqECfbytm48ahHaQyNRfo0QqnPx75/FiTSsbI1EeEBWPPCoV2HknnuSvCfnsd/FirtFE93OuIHhzngG4wvpEyH8d03IZBFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 49D4C2F4; Wed, 1 May 2024 04:09:15 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2FBFB3F793; Wed, 1 May 2024 04:08:48 -0700 (PDT) Date: Wed, 1 May 2024 12:08:45 +0100 From: Sudeep Holla To: Vincenzo Mezzela Cc: gregkh@linuxfoundation.org, javier.carrasco.cruz@gmail.com, julia.lawall@inria.fr, linux-kernel@vger.kernel.org, rafael@kernel.org, skhan@linuxfoundation.org Subject: Re: [PATCH 2/2 v3] drivers: use __free attribute instead of of_node_put() Message-ID: References: <20240424125401.oxvt5n64d7a57ge3@bogus> <20240501094313.407820-1-vincenzo.mezzela@gmail.com> <20240501094313.407820-3-vincenzo.mezzela@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501094313.407820-3-vincenzo.mezzela@gmail.com> As mentioned in 1/2, please fix the subject to be more precise. On Wed, May 01, 2024 at 11:43:13AM +0200, Vincenzo Mezzela wrote: > Introduce the __free attribute for scope-based resource management. > Resources allocated with __free are automatically released at the end of > the scope. This enhancement aims to mitigate memory management issues > associated with forgetting to release resources by utilizing __free > instead of of_node_put(). > > The declaration of the device_node used within the do-while loops is > moved directly within the loop so that the resource is automatically > freed at the end of each iteration. > > Suggested-by: Julia Lawall > Signed-off-by: Vincenzo Mezzela > --- > drivers/base/arch_topology.c | 51 +++++++++++++++--------------------- > 1 file changed, 21 insertions(+), 30 deletions(-) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index ea8836f0bb4b..eef26e304018 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -8,6 +8,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -513,10 +514,10 @@ core_initcall(free_raw_capacity); > */ > static int __init get_cpu_for_node(struct device_node *node) > { > - struct device_node *cpu_node; > int cpu; > > - cpu_node = of_parse_phandle(node, "cpu", 0); > + struct device_node *cpu_node __free(device_node) = > + of_parse_phandle(node, "cpu", 0); Prefer a blank line after this, applies to all the place where you are introducing this style. -- Regards, Sudeep