2021-01-07 13:31:11

by Daniel Scally

[permalink] [raw]
Subject: [PATCH v5 01/15] software_node: Fix refcounts in software_node_get_next_child()

The software_node_get_next_child() function currently does not hold
references to the child software_node that it finds or put the ref that
is held against the old child - fix that.

Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Reviewed-by: Sakari Ailus <[email protected]>
Signed-off-by: Daniel Scally <[email protected]>
---
Changes in v5:

- None

drivers/base/swnode.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 4a4b2008fbc2..4fcc1a6fb724 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -443,14 +443,18 @@ software_node_get_next_child(const struct fwnode_handle *fwnode,
struct swnode *c = to_swnode(child);

if (!p || list_empty(&p->children) ||
- (c && list_is_last(&c->entry, &p->children)))
+ (c && list_is_last(&c->entry, &p->children))) {
+ fwnode_handle_put(child);
return NULL;
+ }

if (c)
c = list_next_entry(c, entry);
else
c = list_first_entry(&p->children, struct swnode, entry);
- return &c->fwnode;
+
+ fwnode_handle_put(child);
+ return fwnode_handle_get(&c->fwnode);
}

static struct fwnode_handle *
--
2.25.1


2021-01-07 13:48:07

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v5 01/15] software_node: Fix refcounts in software_node_get_next_child()

On Thu, Jan 07, 2021 at 01:28:24PM +0000, Daniel Scally wrote:
> The software_node_get_next_child() function currently does not hold
> references to the child software_node that it finds or put the ref that
> is held against the old child - fix that.
>
> Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
> Reviewed-by: Andy Shevchenko <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Sakari Ailus <[email protected]>
> Signed-off-by: Daniel Scally <[email protected]>

Reviewed-by: Heikki Krogerus <[email protected]>

> ---
> Changes in v5:
>
> - None
>
> drivers/base/swnode.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index 4a4b2008fbc2..4fcc1a6fb724 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -443,14 +443,18 @@ software_node_get_next_child(const struct fwnode_handle *fwnode,
> struct swnode *c = to_swnode(child);
>
> if (!p || list_empty(&p->children) ||
> - (c && list_is_last(&c->entry, &p->children)))
> + (c && list_is_last(&c->entry, &p->children))) {
> + fwnode_handle_put(child);
> return NULL;
> + }
>
> if (c)
> c = list_next_entry(c, entry);
> else
> c = list_first_entry(&p->children, struct swnode, entry);
> - return &c->fwnode;
> +
> + fwnode_handle_put(child);
> + return fwnode_handle_get(&c->fwnode);
> }
>
> static struct fwnode_handle *
> --
> 2.25.1

thanks,

--
heikki

2021-01-10 15:12:31

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v5 01/15] software_node: Fix refcounts in software_node_get_next_child()

On Thu, Jan 07, 2021 at 01:28:24PM +0000, Daniel Scally wrote:
> The software_node_get_next_child() function currently does not hold
> references to the child software_node that it finds or put the ref that
> is held against the old child - fix that.
>
> Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
> Reviewed-by: Andy Shevchenko <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Sakari Ailus <[email protected]>
> Signed-off-by: Daniel Scally <[email protected]>
> ---
> Changes in v5:

Acked-by: Greg Kroah-Hartman <[email protected]>