LKML Archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>,
	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()
Date: Wed, 1 May 2024 13:56:00 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2405011355430.3278@hadrien> (raw)
In-Reply-To: <ZjIivZOzGCNNG5QE@bogus>



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 <julia.lawall@inria.fr>
> > Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>
> > ---
> >  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 <linux/acpi.h>
> >  #include <linux/cacheinfo.h>
> > +#include <linux/cleanup.h>
> >  #include <linux/cpu.h>
> >  #include <linux/cpufreq.h>
> >  #include <linux/device.h>
> > @@ -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

  reply	other threads:[~2024-05-01 11:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 13:19 [PATCH] drivers: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-04-19 14:01 ` Sudeep Holla
2024-04-22  8:27   ` Vincenzo Mezzela
2024-04-22 13:09   ` [PATCH v2] " Vincenzo Mezzela
2024-04-24 10:37     ` Sudeep Holla
2024-04-24 12:42       ` Vincenzo Mezzela
2024-04-24 12:54         ` Sudeep Holla
2024-05-01  9:43           ` [PATCH 0/2 v3] drivers: introduce automatic cleanup feature Vincenzo Mezzela
2024-05-01  9:43             ` [PATCH 1/2 v3] drivers: reorganize do-while loops Vincenzo Mezzela
2024-05-01 11:04               ` Sudeep Holla
2024-05-01  9:43             ` [PATCH 2/2 v3] drivers: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-05-01 10:48               ` Greg KH
2024-05-01 12:33                 ` Vincenzo Mezzela
2024-05-01 13:06                   ` Greg KH
2024-05-06 15:30                     ` Vincenzo Mezzela
2024-05-07 10:32                       ` Sudeep Holla
2024-05-01 11:08               ` Sudeep Holla
2024-05-01 11:56                 ` Julia Lawall [this message]
2024-05-01 13:19             ` [PATCH 0/2 v3] drivers: introduce automatic cleanup feature Conor Dooley
2024-05-13  8:13             ` [PATCH 0/2 v4] drivers: arch_topology: " Vincenzo Mezzela
2024-05-13  8:13               ` [PATCH 1/2 v4] drivers: arch_topology: Refactor do-while loops Vincenzo Mezzela
2024-05-13  8:13               ` [PATCH 2/2 v4] drivers: arch_topology: use __free attribute instead of of_node_put() Vincenzo Mezzela
2024-05-13 10:02               ` [PATCH 0/2 v4] drivers: arch_topology: introduce automatic cleanup feature Sudeep Holla
2024-05-14  7:14                 ` Vincenzo Mezzela
2024-05-28  8:23                 ` Vincenzo Mezzela
2024-06-03  8:45                   ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2405011355430.3278@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=sudeep.holla@arm.com \
    --cc=vincenzo.mezzela@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).