lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 5 Apr 2024 12:12:53 -0700
From: Saravana Kannan <saravanak@...gle.com>
To: Rob Herring <robh@...nel.org>
Cc: Jonathan Cameron <jic23@...nel.org>, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] of: Use scope based of_node_put() cleanups

On Fri, Apr 5, 2024 at 6:01 AM Rob Herring <robh@...nel.org> wrote:
>
> On Thu, Apr 4, 2024 at 6:22 PM Saravana Kannan <saravanak@...gle.com> wrote:
> >
> > On Thu, Apr 4, 2024 at 7:15 AM Rob Herring <robh@...nel.org> wrote:
> > >
> > > Use the relatively new scope based of_node_put() cleanup to simplify
> > > function exit handling. Doing so reduces the chances of forgetting an
> > > of_node_put() and simplifies error paths by avoiding the need for goto
> > > statements.
> > >
> > > Signed-off-by: Rob Herring <robh@...nel.org>
> > > ---
> > >  drivers/of/address.c  | 60 ++++++++++++++++-----------------------------------
> > >  drivers/of/property.c | 22 ++++++-------------
> > >  2 files changed, 26 insertions(+), 56 deletions(-)
> > >
> > > diff --git a/drivers/of/address.c b/drivers/of/address.c
> > > index ae46a3605904..f7b2d535a6d1 100644
> > > --- a/drivers/of/address.c
> > > +++ b/drivers/of/address.c
> > > @@ -491,7 +491,6 @@ static u64 __of_translate_address(struct device_node *dev,
> > >                                   const __be32 *in_addr, const char *rprop,
> > >                                   struct device_node **host)
> > >  {
> > > -       struct device_node *parent = NULL;
> > >         struct of_bus *bus, *pbus;
> > >         __be32 addr[OF_MAX_ADDR_CELLS];
> > >         int na, ns, pna, pns;
> > > @@ -504,7 +503,7 @@ static u64 __of_translate_address(struct device_node *dev,
> > >
> > >         *host = NULL;
> > >         /* Get parent & match bus type */
> > > -       parent = get_parent(dev);
> > > +       struct device_node *parent __free(device_node) = get_parent(dev);
> >
> > Can we leave the variable definition where it was? We generally define
> > all the variables up top. So, defining the one variable in the middle
> > feels weird. I at least get when we do this inside for/if blocks. But
> > randomly in the middle feels weird.
>
> There's an 'of_node_get(dev);' before this. Ordering wise, we need to
> hold the ref on the child before we get its parent. I suppose I can
> also convert that to use the cleanups. I'll have to add another local
> ptr to do that though.
>
> >
> > Similar comments in other places. Since both kfree() and of_put() can
> > both handle NULL pointers, I'd be surprised if we HAVE to combine
> > these lines.
>
> https://lore.kernel.org/all/CAHk-=wgRHiV5VSxtfXA4S6aLUmcQYEuB67u3BJPJPtuESs1JyA@mail.gmail.com/

Review-by without reservations.

-Saravana

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ