Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp414478lqm; Wed, 1 May 2024 04:56:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFw781azxo+qgSwRxByuncE/LDrbc/GwytPw+Mriwz4D61NpaODfrZD2Ai37Qf5mHZJ4wbLlqWmJRpW1skjmJ5V+HvS2VmEnyuFQfM0A== X-Google-Smtp-Source: AGHT+IFscW0bc5xqqUAxO0376S2ublPiEmc74P7e4pV8MeBmUu5Sq1qOEQjKRseYzxFwZZgyZMIc X-Received: by 2002:a50:ab51:0:b0:572:a6ec:2396 with SMTP id t17-20020a50ab51000000b00572a6ec2396mr2373799edc.35.1714564575563; Wed, 01 May 2024 04:56:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714564575; cv=pass; d=google.com; s=arc-20160816; b=bDU/IN19S+Xu1rxdHDNMDw1RrAbLuVjNkKd2RuBWLRv5ro8MddgQA2zr/ykSYgwv2f 7HROpd/exI6mOQrdlEL05ZgadSwemBlibwFSXUKE9rds14HRvy/WsBsfIvntN4tqQb7v iwdLTN+LfdnuaHsDgec4nkO8wTotvIrW3lDz2OQ4yas0UC5SqLNMwjHT2OwX3q+K7mxh yoZjh/SXuMy7jfuIl8VKekbb0QIFd2iu1RLXuWBZpnLaY5o8fCF6iOOpzhbukadFUyWg xiutaBDr9PKUWr8hrlIzgRoVCF4mVQNjuL9HsXbC9U43bdoT7YjjFkU0VSCJ/wQAKG8s malg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=ES8+uZdQuIC4h4krwNG6xP2GbtVLZjjoE+7amz2RWV0=; fh=cCM6LB+HSUUC9JGBcM2CGi8nxjOuYN4rz5kPSmm1Qzc=; b=GD+FHYfMi6N69FGcQ7WIiWY8KVAzkb3pUTcqP8HNiSLZwehRYtqU4PS6f6SHV0mAG7 txHPXHk3RDOCtZ7BX1ujpfcO0ZMYZt8KPRXm11hAIDhdEsBeCezEF/8z04IDX/teUVE9 X2zM8vQM2+5ba0jh5CMz5q3D/jcxDlEOcPTfjnBUt1b44pNbNkPdXcqX0KiHypvF4CNB o5JltjvyNB2Wi3D6XVp1fpnLxb4s5RBPVul9BTZGNPhsDZ6eo4tsf5hZuOJB+lX1UoWd T8xtTl1xHeP8JJz/Yk8txtEBkpkdLesHulsICcHHqhBdAM5S74fOys+L2CHcF/qbRAT6 +sxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=tXgRllry; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-165206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y102-20020a50bb6f000000b00571c14f0b29si16594491ede.70.2024.05.01.04.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 04:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=tXgRllry; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-165206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4E2E21F236E2 for ; Wed, 1 May 2024 11:56:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C99EE824A3; Wed, 1 May 2024 11:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="tXgRllry" Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC617C082 for ; Wed, 1 May 2024 11:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714564568; cv=none; b=j8K86Jg/gg4yAISJC5w2gvIJUs5sesJ973p5cO6ZXaGIsb4hiJNZrVMG65TL/zJ/GDdOTyiih3PAGgcqZGfTDTHETKkpyUxZhh2L+1XlZfYZmpbEmHMTUOnhjiZGINnCRyT2chhHGtofg+J8H2eTvkz/UIa55x6dHYr/VIOj99E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714564568; c=relaxed/simple; bh=cKNzn1s8a9SYJT2nlDlwGGXNLaZCx/FBbDmlKkWkTPQ=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=pj/7K+n4Ara3OyIf/pThNgh/7Art9FXoZ+p5Q2dIO4ZUJwTyY9W89dQX88sTCLjHi+rD5HZCfRRhSTFwLE/en2d5IGx9kQN6asiSjSMvXFLnqfZE1i5kitwfE6sudnwA8HD4XSu2B+UnGC0U9ftioqknHdpNVPEAdaJw/o/n8ak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=tXgRllry; arc=none smtp.client-ip=192.134.164.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ES8+uZdQuIC4h4krwNG6xP2GbtVLZjjoE+7amz2RWV0=; b=tXgRllryf0zp5PUoUzlw0YxI+D+l8E6hj+nEvqVYM3FoREdjfxL8QdiM +SG9o3p9Uk/OUZi4Q56Wgqc7YQ3eXvXUcvWgGE1JQJZ9uV4TkJCp2y6IE bbpy7qHHLy9aGPWNF/SyvKI3caC1MlcGRnepHqKwI4YGuWSRZKC31Kp9I 8=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.07,245,1708383600"; d="scan'208";a="86149003" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2024 13:56:01 +0200 Date: Wed, 1 May 2024 13:56:00 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Sudeep Holla cc: Vincenzo Mezzela , 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() In-Reply-To: Message-ID: References: <20240424125401.oxvt5n64d7a57ge3@bogus> <20240501094313.407820-1-vincenzo.mezzela@gmail.com> <20240501094313.407820-3-vincenzo.mezzela@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) 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 On Wed, 1 May 2024, Sudeep Holla wrote: > 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. There should also be no blank line before it. julia