[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024112810-drudge-factor-9bc7@gregkh>
Date: Thu, 28 Nov 2024 12:49:23 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Daniel Scally <djrscally@...il.com>, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] device property: do not leak child nodes when using
NULL/error pointers
On Wed, Nov 27, 2024 at 09:39:34PM -0800, Dmitry Torokhov wrote:
> The documentation to various API calls that locate children for a given
> fwnode (such as fwnode_get_next_available_child_node() or
> device_get_next_child_node()) states that the reference to the node
> passed in "child" argument is dropped unconditionally, however the
> change that added checks for the main node to be NULL or error pointer
> broke this promise.
>
> Add missing fwnode_handle_put() calls to restore the documented
> behavior.
>
> Fixes: 002752af7b89 ("device property: Allow error pointer to be passed to fwnode APIs")
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> ---
> drivers/base/property.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 837d77e3af2b..696ba43b8e8a 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -759,6 +759,12 @@ struct fwnode_handle *
> fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
> struct fwnode_handle *child)
> {
> + if (IS_ERR_OR_NULL(fwnode) ||
> + !fwnode_has_op(fwnode, get_next_child_node)) {
> + fwnode_handle_put(child);
> + return NULL;
> + }
> +
> return fwnode_call_ptr_op(fwnode, get_next_child_node, child);
> }
> EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
> @@ -778,9 +784,6 @@ fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
> {
> struct fwnode_handle *next_child = child;
>
> - if (IS_ERR_OR_NULL(fwnode))
> - return NULL;
> -
> do {
> next_child = fwnode_get_next_child_node(fwnode, next_child);
> if (!next_child)
> @@ -806,8 +809,10 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev,
> const struct fwnode_handle *fwnode = dev_fwnode(dev);
> struct fwnode_handle *next;
>
> - if (IS_ERR_OR_NULL(fwnode))
> + if (IS_ERR_OR_NULL(fwnode)) {
> + fwnode_handle_put(child);
> return NULL;
> + }
>
> /* Try to find a child in primary fwnode */
> next = fwnode_get_next_child_node(fwnode, child);
> --
> 2.47.0.338.g60cca15819-goog
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
Powered by blists - more mailing lists