swrap: Fix coverity issues
authorAnoop C S <anoopcs@redhat.com>
Fri, 26 Oct 2018 10:14:53 +0000 (15:44 +0530)
committerAndreas Schneider <asn@samba.org>
Mon, 29 Oct 2018 19:31:43 +0000 (20:31 +0100)
CID 184220
CID 184221

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/socket_wrapper.c

index 0f19b95d7abbc743d8841789abdc94a99a927719..5e3a47bfec61fa2184d2fada93898a04216af374 100644 (file)
@@ -2055,8 +2055,6 @@ static void swrap_remove_stale(int fd)
 
        reset_socket_info_index(fd);
 
-       swrap_mutex_unlock(&socket_reset_mutex);
-
        si = swrap_get_socket_info(si_index);
 
        swrap_mutex_lock(&first_free_mutex);
@@ -2078,6 +2076,7 @@ static void swrap_remove_stale(int fd)
 out:
        SWRAP_UNLOCK_SI(si);
        swrap_mutex_unlock(&first_free_mutex);
+       swrap_mutex_unlock(&socket_reset_mutex);
 }
 
 static int sockaddr_convert_to_un(struct socket_info *si,
@@ -5935,8 +5934,6 @@ static int swrap_close(int fd)
 
        reset_socket_info_index(fd);
 
-       swrap_mutex_unlock(&socket_reset_mutex);
-
        si = swrap_get_socket_info(si_index);
 
        swrap_mutex_lock(&first_free_mutex);
@@ -5970,6 +5967,7 @@ static int swrap_close(int fd)
 out:
        SWRAP_UNLOCK_SI(si);
        swrap_mutex_unlock(&first_free_mutex);
+       swrap_mutex_unlock(&socket_reset_mutex);
 
        return ret;
 }