lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241015-fwdevlink-probed-no-err-v2-1-756c5e9cf55c@collabora.com>
Date: Tue, 15 Oct 2024 17:27:17 -0400
From: Nícolas F. R. A. Prado <nfraprado@...labora.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 "Rafael J. Wysocki" <rafael@...nel.org>, 
 Saravana Kannan <saravanak@...gle.com>
Cc: kernel@...labora.com, linux-kernel@...r.kernel.org, 
 Jon Hunter <jonathanh@...dia.com>, 
 Nícolas F. R. A. Prado <nfraprado@...labora.com>
Subject: [PATCH v2 1/2] driver core: Create device_link_is_useless() helper

Create a device_link_is_useless() helper to encapsulate the logic that
checks whether a device link is useless and use that instead.

Suggested-by: Saravana Kannan <saravanak@...gle.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@...labora.com>
---
 drivers/base/core.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index b69b82da8837ebb6b3497d52d46a43e26ea1c64a..88a47a6e26d69aacbaeb094c42be4fcf9dde4a6b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -668,6 +668,19 @@ postcore_initcall(devlink_class_init);
 #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
 			    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
 
+static bool device_link_is_useless(u32 flags, struct device *consumer)
+{
+	/*
+	 * SYNC_STATE_ONLY links are useless once a consumer device has probed.
+	 */
+	if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+	    consumer->links.status != DL_DEV_NO_DRIVER &&
+	    consumer->links.status != DL_DEV_PROBING)
+		return true;
+
+	return false;
+}
+
 /**
  * device_link_add - Create a link between two devices.
  * @consumer: Consumer end of the link.
@@ -771,13 +784,7 @@ struct device_link *device_link_add(struct device *consumer,
 		goto out;
 	}
 
-	/*
-	 * SYNC_STATE_ONLY links are useless once a consumer device has probed.
-	 * So, only create it if the consumer hasn't probed yet.
-	 */
-	if (flags & DL_FLAG_SYNC_STATE_ONLY &&
-	    consumer->links.status != DL_DEV_NO_DRIVER &&
-	    consumer->links.status != DL_DEV_PROBING) {
+	if (device_link_is_useless(flags, consumer)) {
 		link = NULL;
 		goto out;
 	}

-- 
2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ