Review at  https://gerrit.osmocom.org/3236

VIRT-PHY: mcast_sock: properly clean up in error paths (close/unreg socket)

Change-Id: I2c22359735af6b867e25e0f566cadbc88f21ef44
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/36/3236/1

diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c 
b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index 11a1aa9..3a3c77a 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -42,6 +42,7 @@
        rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, 
sizeof(loopback));
        if (rc < 0) {
                perror("Failed to configure multicast loopback.\n");
+               fd_close(ofd);
                return rc;
        }
 
@@ -77,6 +78,7 @@
                        &loopback, sizeof(loopback));
        if (rc < 0) {
                perror("Failed to enable IP_MULTICAST_LOOP");
+               fd_close(ofd);
                return rc;
        }
 
@@ -87,6 +89,7 @@
        rc = setsockopt(ofd->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, 
sizeof(mreq));
        if (rc < 0) {
                perror("Failed to join to mcast goup");
+               fd_close(ofd);
                return rc;
        }
 
@@ -94,6 +97,7 @@
         * from sockets we are subscribed to via IP_ADD_MEMBERSHIP are received 
*/
        if (setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_ALL, &all, 
sizeof(all)) < 0) {
                perror("Failed to modify delivery policy to explicitly 
joined.\n");
+               fd_close(ofd);
                return rc;
        }
 

-- 
To view, visit https://gerrit.osmocom.org/3236
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c22359735af6b867e25e0f566cadbc88f21ef44
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to