On Fri, Apr 5, 2024 at 6:01 AM Rob Herring <robh@xxxxxxxxxx> wrote: > > On Thu, Apr 4, 2024 at 6:22 PM Saravana Kannan <saravanak@xxxxxxxxxx> wrote: > > > > On Thu, Apr 4, 2024 at 7:15 AM Rob Herring <robh@xxxxxxxxxx> 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@xxxxxxxxxx> > > > --- > > > 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@xxxxxxxxxxxxxx/ Review-by without reservations. -Saravana