From 8ba0d9cf9769579f3c68f78b33477c10aa133e8c Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Fri, 15 Jun 2018 12:36:54 +0530 Subject: swrap: Fix thread deadlock found by Coverity scan CID 175897 CID 175898 Signed-off-by: Anoop C S Reviewed-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- src/socket_wrapper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/socket_wrapper.c') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index d9076f6..1a91c0e 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -4656,13 +4656,14 @@ static ssize_t swrap_sendmsg_before(int fd, if (si->bound == 0) { ret = swrap_auto_bind(fd, si, si->family); if (ret == -1) { + SWRAP_UNLOCK_SI(si); if (errno == ENOTSOCK) { swrap_remove_stale(fd); ret = -ENOTSOCK; } else { SWRAP_LOG(SWRAP_LOG_ERROR, "swrap_sendmsg_before failed"); } - goto out; + return ret; } } @@ -4866,6 +4867,7 @@ static int swrap_recvmsg_before(int fd, if (si->bound == 0) { ret = swrap_auto_bind(fd, si, si->family); if (ret == -1) { + SWRAP_UNLOCK_SI(si); /* * When attempting to read or write to a * descriptor, if an underlying autobind fails @@ -4879,7 +4881,7 @@ static int swrap_recvmsg_before(int fd, SWRAP_LOG(SWRAP_LOG_ERROR, "swrap_recvmsg_before failed"); } - goto out; + return ret; } } break; -- cgit