]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgrulesengd: Fix Coverity warnings about a socket leak
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 7 Jan 2020 14:50:03 +0000 (07:50 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 8 Jan 2020 15:01:39 +0000 (08:01 -0700)
This commit resolves the following Coverity warnings:

CID 1412123 (#1 of 1): Resource leak (RESOURCE_LEAK)12. leaked_handle:
Handle variable sk_nl going out of scope leaks the handle.

CID 1412129 (#1 of 1): Resource leak (RESOURCE_LEAK)13. leaked_handle:
Handle variable sk_unix going out of scope leaks the handle.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/daemon/cgrulesengd.c

index 5efc00eb9aed6d4745cb953b6f9b261bb8d8a7ea..4cef53ee0e10bdd235bd3f8fcfe2b011b0e479de 100644 (file)
@@ -792,9 +792,9 @@ static int cgre_create_netlink_socket_process_msg(void)
        }
 
 close_and_exit:
-       if (sk_nl > 0)
+       if (sk_nl >= 0)
                close(sk_nl);
-       if (sk_unix > 0)
+       if (sk_unix >= 0)
                close(sk_unix);
        return rc;
 }