[CRIU] [PATCH 2/9] cr-check: don't forget close a test socket
Andrey Vagin
avagin at openvz.org
Thu Apr 4 17:44:28 EDT 2013
CID 996206 (#3 of 3): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable "sk" going out of scope leaks the handle.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-check.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/cr-check.c b/cr-check.c
index 3e2c16b..1045988 100644
--- a/cr-check.c
+++ b/cr-check.c
@@ -398,7 +398,7 @@ static int check_unaligned_vmsplice(void)
static int check_so_gets(void)
{
- int sk;
+ int sk, ret = -1;
socklen_t len;
char name[IFNAMSIZ];
@@ -411,16 +411,19 @@ static int check_so_gets(void)
len = 0;
if (getsockopt(sk, SOL_SOCKET, SO_GET_FILTER, NULL, &len)) {
pr_perror("Can't get socket filter");
- return -1;
+ goto err;
}
len = sizeof(name);
if (getsockopt(sk, SOL_SOCKET, SO_BINDTODEVICE, name, &len)) {
pr_perror("Can't get socket bound dev");
- return -1;
+ goto err;
}
- return 0;
+ ret = 0;
+err:
+ close(sk);
+ return ret;
}
static int check_ipc(void)
--
1.7.11.7
More information about the CRIU
mailing list