aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-01-05 14:33:29 +0100
committerfixeria <vyanitskiy@sysmocom.de>2021-01-05 15:21:39 +0000
commit222e8447187ed75bcc89cf3a0e483f1f684074d0 (patch)
tree745f1c916f1fba0342e1564d95244114561f64ee
parentd8b7003df7a3a554af22762e150c7201781e0485 (diff)
gprs_ns2_fr: fix resource leaks due to early return in set_ifupdown()
Change-Id: Ie52bf8ac6d62e7f2d760294bf2fe90119cc96b4b Related: CID#215869
-rw-r--r--src/gb/gprs_ns2_fr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index ca2d38cf..2c797f32 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -448,11 +448,15 @@ static int set_ifupdown(const char *netif, bool up)
OSMO_STRLCPY_ARRAY(req.ifr_name, netif);
rc = ioctl(sock, SIOCGIFFLAGS, &req);
- if (rc < 0)
+ if (rc < 0) {
+ close(sock);
return rc;
+ }
- if ((req.ifr_flags & IFF_UP) == up)
+ if ((req.ifr_flags & IFF_UP) == up) {
+ close(sock);
return 0;
+ }
if (up)
req.ifr_flags |= IFF_UP;