diff mbox series

[1/7] device property: Fix fwnode_graph_devcon_match() fwnode leak

Message ID 20211130153250.935726-1-sakari.ailus@linux.intel.com (mailing list archive)
State Superseded, archived
Headers show
Series [1/7] device property: Fix fwnode_graph_devcon_match() fwnode leak | expand

Commit Message

Sakari Ailus Nov. 30, 2021, 3:32 p.m. UTC
For each endpoint it encounters, fwnode_graph_devcon_match() checks
whether the endpoint's remote port parent device is available. If it is
not, it ignores the endpoint but does not put the reference to the remote
endpoint port parent fwnode. For available devices the fwnode handle
reference is put as expected.

Put the reference for unavailable devices now.

Fixes: 637e9e52b185 ("device connection: Find device connections also from device graphs")
Cc: stable@vger.kernel.org # for 5.1 and later
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/base/property.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko Nov. 30, 2021, 4:07 p.m. UTC | #1
On Tue, Nov 30, 2021 at 05:32:44PM +0200, Sakari Ailus wrote:
> For each endpoint it encounters, fwnode_graph_devcon_match() checks
> whether the endpoint's remote port parent device is available. If it is
> not, it ignores the endpoint but does not put the reference to the remote
> endpoint port parent fwnode. For available devices the fwnode handle
> reference is put as expected.
> 
> Put the reference for unavailable devices now.

I like the series, thanks!
For non-commented you may take my
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

The rest can gain it if you are okay with my proposals.

Also, please fix Cc list, it has fancy address in the Cc list.

> Fixes: 637e9e52b185 ("device connection: Find device connections also from device graphs")
> Cc: stable@vger.kernel.org # for 5.1 and later
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/base/property.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index f1f35b48ab8b9..6df99e526ab0f 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -1206,8 +1206,10 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
>  
>  	fwnode_graph_for_each_endpoint(fwnode, ep) {
>  		node = fwnode_graph_get_remote_port_parent(ep);
> -		if (!fwnode_device_is_available(node))
> +		if (!fwnode_device_is_available(node)) {
> +			fwnode_handle_put(node);
>  			continue;
> +		}
>  
>  		ret = match(node, con_id, data);
>  		fwnode_handle_put(node);
> -- 
> 2.30.2
>
Sakari Ailus Nov. 30, 2021, 8:21 p.m. UTC | #2
Hi Andy,

Thanks for the comments.

On Tue, Nov 30, 2021 at 06:07:26PM +0200, Andy Shevchenko wrote:
> On Tue, Nov 30, 2021 at 05:32:44PM +0200, Sakari Ailus wrote:
> > For each endpoint it encounters, fwnode_graph_devcon_match() checks
> > whether the endpoint's remote port parent device is available. If it is
> > not, it ignores the endpoint but does not put the reference to the remote
> > endpoint port parent fwnode. For available devices the fwnode handle
> > reference is put as expected.
> > 
> > Put the reference for unavailable devices now.
> 
> I like the series, thanks!
> For non-commented you may take my
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks!

> 
> The rest can gain it if you are okay with my proposals.
> 
> Also, please fix Cc list, it has fancy address in the Cc list.

I forgot to write one more e-mail address before pressing enter...
Sakari Ailus Dec. 1, 2021, 1:19 p.m. UTC | #3
On Tue, Nov 30, 2021 at 06:07:26PM +0200, Andy Shevchenko wrote:
> On Tue, Nov 30, 2021 at 05:32:44PM +0200, Sakari Ailus wrote:
> > For each endpoint it encounters, fwnode_graph_devcon_match() checks
> > whether the endpoint's remote port parent device is available. If it is
> > not, it ignores the endpoint but does not put the reference to the remote
> > endpoint port parent fwnode. For available devices the fwnode handle
> > reference is put as expected.
> > 
> > Put the reference for unavailable devices now.
> 
> I like the series, thanks!
> For non-commented you may take my
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> The rest can gain it if you are okay with my proposals.
> 
> Also, please fix Cc list, it has fancy address in the Cc list.

Just sent v2, with your acks:

<URL:https://lore.kernel.org/linux-acpi/20211201125934.936953-1-sakari.ailus@linux.intel.com/T/#t>
diff mbox series

Patch

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f1f35b48ab8b9..6df99e526ab0f 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1206,8 +1206,10 @@  fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
 
 	fwnode_graph_for_each_endpoint(fwnode, ep) {
 		node = fwnode_graph_get_remote_port_parent(ep);
-		if (!fwnode_device_is_available(node))
+		if (!fwnode_device_is_available(node)) {
+			fwnode_handle_put(node);
 			continue;
+		}
 
 		ret = match(node, con_id, data);
 		fwnode_handle_put(node);