From: Markus Elfring <elfr...@users.sourceforge.net>
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 <elfr...@users.sourceforge.net>
---
 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

Reply via email to