Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1242229 > unrolled thread

[PATCH 36/44] kdbus: Improve kdbus_name_release()

Started bySergei Zviagintsev <sergei@s15v.net>
First post2015-10-08 13:40 +0200
Last post2015-10-08 13:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 36/44] kdbus: Improve kdbus_name_release() Sergei Zviagintsev <sergei@s15v.net> - 2015-10-08 13:40 +0200

#1242229 — [PATCH 36/44] kdbus: Improve kdbus_name_release()

FromSergei Zviagintsev <sergei@s15v.net>
Date2015-10-08 13:40 +0200
Subject[PATCH 36/44] kdbus: Improve kdbus_name_release()
Message-ID<qhhId-2d4-15@gated-at.bofh.it>
Use goto to handle error paths in conventional way.

Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
---
 ipc/kdbus/names.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c
index a1c3442f8e53..8e53681d1b7b 100644
--- a/ipc/kdbus/names.c
+++ b/ipc/kdbus/names.c
@@ -474,18 +474,23 @@ static int kdbus_name_release(struct kdbus_name_registry *reg,
 	int ret = 0;
 
 	down_write(&reg->rwlock);
+
 	name = kdbus_name_entry_find(reg, kdbus_strhash(name_str), name_str);
-	if (name) {
-		owner = kdbus_name_owner_find(name, conn);
-		if (owner)
-			kdbus_name_release_unlocked(owner);
-		else
-			ret = -EADDRINUSE;
-	} else {
+	if (!name) {
 		ret = -ESRCH;
+		goto exit;
 	}
-	up_write(&reg->rwlock);
 
+	owner = kdbus_name_owner_find(name, conn);
+	if (!owner) {
+		ret = -EADDRINUSE;
+		goto exit;
+	}
+
+	kdbus_name_release_unlocked(owner);
+
+exit:
+	up_write(&reg->rwlock);
 	kdbus_notify_flush(conn->ep->bus);
 	return ret;
 }
-- 
1.8.3.1

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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web