Re: [PATCH 2/3] of: dynamic: add of_node_alloc() and of_node_free()
From: Rob Herring
Date: Thu May 05 2022 - 15:44:09 EST
On Wed, May 04, 2022 at 05:40:32PM +0200, Clément Léger wrote:
> Add functions which allows to create and free nodes.
>
> Signed-off-by: Clément Léger <clement.leger@xxxxxxxxxxx>
> ---
> drivers/of/dynamic.c | 59 ++++++++++++++++++++++++++++++++++++--------
> include/linux/of.h | 9 +++++++
> 2 files changed, 58 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> index e8700e509d2e..ec28e5ba2969 100644
> --- a/drivers/of/dynamic.c
> +++ b/drivers/of/dynamic.c
> @@ -455,6 +455,54 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
> prop->length, allocflags);
> }
>
> +/**
> + * of_node_free - Free a node allocated dynamically.
> + * @node: Node to be freed
> + */
> +void of_node_free(const struct device_node *node)
> +{
> + kfree(node->full_name);
> + kfree(node->data);
> + kfree(node);
> +}
> +EXPORT_SYMBOL(of_node_free);
This shouldn't be needed. Nodes are refcounted, so any caller should
just do a put.
Rob