mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Herve Codina <herve.codina@bootlin.com>
Cc: Saravana Kannan <saravanak@google.com>,
	Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	linux-kernel@vger.kernel.org,
	Allan Nielsen <allan.nielsen@microchip.com>,
	Horatiu Vultur <horatiu.vultur@microchip.com>,
	Steen Hegelund <steen.hegelund@microchip.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/1] lib/vsprintf: Fix %pfwf when current node refcount == 0
Date: Tue, 14 Nov 2023 12:29:28 +0000	[thread overview]
Message-ID: <ZVNoKAHlb1CXnND7@kekkonen.localdomain> (raw)
In-Reply-To: <20231114124832.40d4ced4@bootlin.com>

Hi Herve,

On Tue, Nov 14, 2023 at 12:48:32PM +0100, Herve Codina wrote:
> Hi Sakari,
> 
> On Tue, 14 Nov 2023 11:28:43 +0000
> Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
> 
> > > --- a/lib/vsprintf.c
> > > +++ b/lib/vsprintf.c
> > > @@ -2108,8 +2108,8 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf,
> > >  {
> > >  	int depth;
> > >  
> > > -	/* Loop starting from the root node to the current node. */
> > > -	for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) {
> > > +	/* Loop starting from the root node to the parent of current node. */
> > > +	for (depth = fwnode_count_parents(fwnode); depth > 0; depth--) {
> > >  		struct fwnode_handle *__fwnode =
> > >  			fwnode_get_nth_parent(fwnode, depth);  
> > 
> > How about, without changing the loop:
> > 
> > 		/*
> > 		 * Only get a reference for other nodes, fwnode refcount
> > 		 * may be 0 here.
> > 		 */
> > 		struct fwnode_handle *__fwnode =
> > 			depth ? fwnode_get_nth_parent(fwnode, depth) : fwnode;
> > 
> > >  
> > > @@ -2121,6 +2121,16 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf,
> > >  		fwnode_handle_put(__fwnode);  
> > 
> > And:
> > 
> > 		if (__fwnode != fwnode)
> > 			fwnode_handle_put(__fwnode);
> > 
> 
> Sure.
> I will just change to keep the both tests consistent.
> I mean test with depth or test with __fwnode != fwnode but avoid
> mixing them.
> 
> What do you think about testing using depth in all cases and so:
> 	if (depth)
> 		fwnode_handle_put(__fwnode);

I'd compare fwnodes as we're putting __fwnode since we've gotten a
reference to fwnodes different from fwnode. I don't have a strong opinion
on this though, up to you.

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2023-11-14 12:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 11:04 Herve Codina
2023-11-14 11:28 ` Sakari Ailus
2023-11-14 11:48   ` Herve Codina
2023-11-14 12:29     ` Sakari Ailus [this message]
2023-11-14 13:12 ` Andy Shevchenko
2023-11-14 13:19   ` Herve Codina
2023-11-14 13:27     ` Andy Shevchenko
2023-11-14 13:28       ` Andy Shevchenko

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=ZVNoKAHlb1CXnND7@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=herve.codina@bootlin.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pmladek@suse.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=saravanak@google.com \
    --cc=senozhatsky@chromium.org \
    --cc=stable@vger.kernel.org \
    --cc=steen.hegelund@microchip.com \
    --cc=thomas.petazzoni@bootlin.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

all inboxes | Powered by JetHome®