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]
Date:	Thu,  8 Oct 2015 14:32:01 +0300
From:	Sergei Zviagintsev <sergei@...v.net>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Daniel Mack <daniel@...que.org>,
	David Herrmann <dh.herrmann@...glemail.com>,
	Djalal Harouni <tixxdz@...ndz.org>
Cc:	linux-kernel@...r.kernel.org, Sergei Zviagintsev <sergei@...v.net>
Subject: [PATCH 32/44] kdbus: Remove duplicated code from kdbus_conn_lock2()

Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
 ipc/kdbus/connection.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/ipc/kdbus/connection.h b/ipc/kdbus/connection.h
index 679f393d3e68..3b382b604348 100644
--- a/ipc/kdbus/connection.h
+++ b/ipc/kdbus/connection.h
@@ -215,17 +215,13 @@ static inline int kdbus_conn_is_monitor(const struct kdbus_conn *conn)
  */
 static inline void kdbus_conn_lock2(struct kdbus_conn *a, struct kdbus_conn *b)
 {
-	if (a < b) {
-		if (a)
-			mutex_lock(&a->lock);
-		if (b && b != a)
-			mutex_lock_nested(&b->lock, !!a);
-	} else {
-		if (b)
-			mutex_lock(&b->lock);
-		if (a && a != b)
-			mutex_lock_nested(&a->lock, !!b);
-	}
+	struct kdbus_conn *lo = min(a, b);
+	struct kdbus_conn *hi = max(a, b);
+
+	if (lo)
+		mutex_lock(&lo->lock);
+	if (hi && hi != lo)
+		mutex_lock_nested(&hi->lock, !!lo);
 }
 
 /**
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ