]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api: fix missing goto in cgroup_get_current_controller_path()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 4 Jul 2023 06:34:51 +0000 (12:04 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 5 Jul 2023 15:06:01 +0000 (09:06 -0600)
Fix missing goto on error in cgroup_get_current_controller_path(), it
was reported by Coverity tool as unused value:

CID 320875 (#1 of 1): Unused value (UNUSED_VALUE)assigned_value:
Assigning value ECGOTHER to ret here, but that stored value is
overwritten before it can be used.

It turns out that, it is more than an over-written value, the strdup()
was missing goto error path statement on failure, add it.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c

index e24805cda7e6326769db9bf375c5ac2b783bca4b..0a4f0066bb91f9d4055ad52f873dccf86fe17ce2 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -4936,6 +4936,7 @@ int cgroup_get_current_controller_path(pid_t pid, const char *controller, char *
                        if (!*current_path) {
                                last_errno = errno;
                                ret = ECGOTHER;
+                               goto done;
                        }
                        ret = 0;
                        goto done;