Skip to content

Commit

Permalink
cr-check: don't forget close a test socket
Browse files Browse the repository at this point in the history
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@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
  • Loading branch information
avagin authored and xemul committed Apr 5, 2013
1 parent 4ef1524 commit 5d244ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cr-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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)
Expand Down

0 comments on commit 5d244ca

Please sign in to comment.