lkml.org 
[lkml]   [2023]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/1] lib/vsprintf: Fix %pfwf when current node refcount == 0
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);

Best regards,
Hervé

\
 
 \ /
  Last update: 2023-11-20 13:59    [W:0.092 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site