linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] driver core: fw_devlink: Don't create device links for devices not on a bus
@ 2021-08-31 22:45 Saravana Kannan
  2021-09-01  6:24 ` Greg Kroah-Hartman
  2021-09-01 15:44 ` Ulf Hansson
  0 siblings, 2 replies; 11+ messages in thread
From: Saravana Kannan @ 2021-08-31 22:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan
  Cc: Ulf Hansson, Marek Szyprowski, kernel-team, linux-kernel

Devices that are not on a bus will never have a driver bound to it. So,
fw_devlink should not create device links for it as it can cause probe
issues[1] or sync_state() call back issues[2].

[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/
Fixes: f9aa460672c9 ("driver core: Refactor fw_devlink feature")
Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
 drivers/base/core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index f6360490a4a3..304a06314656 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,
 	struct device *sup_dev;
 	int ret = 0;
 
+	/*
+	 * If a consumer device is not on a bus (i.e. a driver will never bind
+	 * to it), it doesn't make sense for fw_devlink to create device links
+	 * for it.
+	 */
+	if (con->bus == NULL)
+		return -EINVAL;
+
 	sup_dev = get_dev_from_fwnode(sup_handle);
 	if (sup_dev) {
+		/*
+		 * If a supplier device is not on a bus (i.e. a driver will
+		 * never bind to it), it doesn't make sense for fw_devlink to
+		 * create device links for it.
+		 */
+		if (sup_dev->bus == NULL)
+			return -EINVAL;
+
 		/*
 		 * If it's one of those drivers that don't actually bind to
 		 * their device using driver core, then don't wait on this
-- 
2.33.0.259.gc128427fd7-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-02  1:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 22:45 [PATCH v1] driver core: fw_devlink: Don't create device links for devices not on a bus Saravana Kannan
2021-09-01  6:24 ` Greg Kroah-Hartman
2021-09-01  6:57   ` Saravana Kannan
2021-09-01  7:14     ` Greg Kroah-Hartman
2021-09-01 21:55       ` Saravana Kannan
2021-09-01 22:11         ` Ulf Hansson
2021-09-01 15:44 ` Ulf Hansson
2021-09-01 21:53   ` Saravana Kannan
2021-09-01 22:17     ` Ulf Hansson
2021-09-02  0:16       ` Saravana Kannan
2021-09-02  1:43         ` Saravana Kannan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).