[PATCH 1/2] tipc: Use common error handling code in tipc_server_start()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Nov 2017 22:18:35 +0100

* Improve jump targets so that a bit of exception handling can be better
  reused at the end of this function.

* Adjust two condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 net/tipc/server.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/net/tipc/server.c b/net/tipc/server.c
index acaef80fb88c..7359d37e39cd 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -670,16 +670,19 @@ int tipc_server_start(struct tipc_server *s)
 		return -ENOMEM;
 
 	ret = tipc_work_start(s);
-	if (ret < 0) {
-		kmem_cache_destroy(s->rcvbuf_cache);
-		return ret;
-	}
+	if (ret)
+		goto destroy_cache;
+
 	ret = tipc_open_listening_sock(s);
-	if (ret < 0) {
-		tipc_work_stop(s);
-		kmem_cache_destroy(s->rcvbuf_cache);
-		return ret;
-	}
+	if (ret)
+		goto stop_work;
+
+	return 0;
+
+stop_work:
+	tipc_work_stop(s);
+destroy_cache:
+	kmem_cache_destroy(s->rcvbuf_cache);
 	return ret;
 }
 
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux