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

From: Sergei Zviagintsev
Date: Thu Oct 08 2015 - 07:37:38 EST


Use goto to handle error paths in conventional way.

Signed-off-by: Sergei Zviagintsev <sergei@xxxxxxxx>
---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/