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:03 +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 34/44] kdbus: Improve kdbus_conn_entry_sync_attach()

Use goto to handle error paths in conventional way. Use conditional
operator instead of `remote_ret' var. Update the comment on waking up
remote peer.

Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
 ipc/kdbus/connection.c | 52 ++++++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
index 6ee688d3de53..081f248339f5 100644
--- a/ipc/kdbus/connection.c
+++ b/ipc/kdbus/connection.c
@@ -820,47 +820,37 @@ static int kdbus_conn_entry_sync_attach(struct kdbus_conn *conn_dst,
 					struct kdbus_reply *reply_wake)
 {
 	struct kdbus_queue_entry *entry;
-	int remote_ret, ret = 0;
+	int ret = 0;
 
 	mutex_lock(&reply_wake->reply_dst->lock);
 
-	/*
-	 * If we are still waiting then proceed, allocate a queue
-	 * entry and attach it to the reply object
-	 */
-	if (reply_wake->waiting) {
-		entry = kdbus_conn_entry_make(reply_wake->reply_src, conn_dst,
-					      staging);
-		if (IS_ERR(entry))
-			ret = PTR_ERR(entry);
-		else
-			/* Attach the entry to the reply object */
-			reply_wake->queue_entry = entry;
-	} else {
+	if (!reply_wake->waiting) {
 		ret = -ECONNRESET;
+		goto wake_up_remote;
 	}
 
 	/*
-	 * Update the reply object and wake up remote peer only
-	 * on appropriate return codes
-	 *
-	 * * -ECOMM: if the replying connection failed with -ECOMM
-	 *           then wakeup remote peer with -EREMOTEIO
-	 *
-	 *           We do this to differenciate between -ECOMM errors
-	 *           from the original sender perspective:
-	 *           -ECOMM error during the sync send and
-	 *           -ECOMM error during the sync reply, this last
-	 *           one is rewritten to -EREMOTEIO
-	 *
-	 * * Wake up on all other return codes.
+	 * We are still waiting. Allocate a queue entry and attach it to the
+	 * reply object.
 	 */
-	remote_ret = ret;
+	entry = kdbus_conn_entry_make(reply_wake->reply_src, conn_dst, staging);
+	if (IS_ERR(entry)) {
+		ret = PTR_ERR(entry);
+		goto wake_up_remote;
+	}
 
-	if (ret == -ECOMM)
-		remote_ret = -EREMOTEIO;
+	reply_wake->queue_entry = entry;
 
-	kdbus_sync_reply_wakeup(reply_wake, remote_ret);
+	/*
+	 * If the replying connection failed with -ECOMM then wakeup remote peer
+	 * with -EREMOTEIO. We do this to differentiate between -ECOMM errors
+	 * from the original sender perspective:
+	 *   * -ECOMM error during the sync send and
+	 *   * -ECOMM error during the sync reply, this last one is rewritten
+	 *     to -EREMOTEIO
+	 */
+wake_up_remote:
+	kdbus_sync_reply_wakeup(reply_wake, (ret == -ECOMM) ? -EREMOTEIO : ret);
 	kdbus_reply_unlink(reply_wake);
 	mutex_unlock(&reply_wake->reply_dst->lock);
 
-- 
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