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:31:55 +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 26/44] kdbus: Cleanup kdbus_pin_dst()

 - Reduce scope of `owner' var to the block where it is actually used.
   Use conditional operator to set its value.

 - Drop initialization of `dst' as it gets value later.

 - Drop separate exit point as we have only one use case of it.

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

diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
index 6a73ac3f444d..ace587ee951a 100644
--- a/ipc/kdbus/connection.c
+++ b/ipc/kdbus/connection.c
@@ -1048,10 +1048,8 @@ static int kdbus_pin_dst(struct kdbus_bus *bus,
 			 struct kdbus_conn **out_dst)
 {
 	const struct kdbus_msg *msg = staging->msg;
-	struct kdbus_name_owner *owner = NULL;
 	struct kdbus_name_entry *name = NULL;
-	struct kdbus_conn *dst = NULL;
-	int ret;
+	struct kdbus_conn *dst;
 
 	lockdep_assert_held(&bus->name_registry->rwlock);
 
@@ -1061,14 +1059,15 @@ static int kdbus_pin_dst(struct kdbus_bus *bus,
 			return -ENXIO;
 
 		if (!kdbus_conn_is_ordinary(dst)) {
-			ret = -ENXIO;
-			goto error;
+			kdbus_conn_unref(dst);
+			return -ENXIO;
 		}
 	} else {
+		struct kdbus_name_owner *owner;
+
 		name = kdbus_name_lookup_unlocked(bus->name_registry,
 						  staging->dst_name);
-		if (name)
-			owner = kdbus_name_get_owner(name);
+		owner = name ? kdbus_name_get_owner(name) : NULL;
 		if (!owner)
 			return -ESRCH;
 
@@ -1094,10 +1093,6 @@ static int kdbus_pin_dst(struct kdbus_bus *bus,
 	*out_name = name;
 	*out_dst = dst;
 	return 0;
-
-error:
-	kdbus_conn_unref(dst);
-	return ret;
 }
 
 static int kdbus_conn_reply(struct kdbus_conn *src,
-- 
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