All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: andriy.shevchenko@linux.intel.com,
	heikki.krogerus@linux.intel.com, rafael@kernel.org
Subject: [PATCH v2 1/7] device property: Fix fwnode_graph_devcon_match() fwnode leak
Date: Wed,  1 Dec 2021 14:59:29 +0200	[thread overview]
Message-ID: <20211201125934.936953-2-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20211201125934.936953-1-sakari.ailus@linux.intel.com>

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>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@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


  reply	other threads:[~2021-12-01 12:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 12:59 [PATCH v2 0/7] Small device property fixes and improvements Sakari Ailus
2021-12-01 12:59 ` Sakari Ailus [this message]
2021-12-01 12:59 ` [PATCH v2 2/7] device property: Fix documentation for FWNODE_GRAPH_DEVICE_DISABLED Sakari Ailus
2021-12-01 12:59 ` [PATCH v2 3/7] Documentation: ACPI: Fix data node reference documentation Sakari Ailus
2021-12-01 12:59 ` [PATCH v2 4/7] Documentation: ACPI: Update references Sakari Ailus
2021-12-01 12:59 ` [PATCH v2 5/7] device property: Implement fwnode_graph_get_endpoint_count() Sakari Ailus
2021-12-01 12:59 ` [PATCH v2 6/7] device property: Use fwnode_graph_for_each_endpoint() macro Sakari Ailus
2021-12-01 13:01 ` [PATCH v2 7/7] device property: Drop fwnode_graph_get_remote_node() Sakari Ailus
2021-12-17 17:43 ` [PATCH v2 0/7] Small device property fixes and improvements Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211201125934.936953-2-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.