On 1/16/20 10:43 AM, Nikola Forró wrote:
Signed-off-by: Nikola Forró <nfo...@redhat.com>

Reviewed-by: Tom Hromatka <tom.hroma...@oracle.com>

---
  src/api.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/api.c b/src/api.c
index e7a07cf..96e082f 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1382,12 +1382,15 @@ static int __cgroup_attach_task_pid(char *path, pid_t 
tid)
        if (!tasks) {
                switch (errno) {
                case EPERM:
-                       return ECGROUPNOTOWNER;
+                       ret = ECGROUPNOTOWNER;
+                       break;
                case ENOENT:
-                       return ECGROUPNOTEXIST;
+                       ret = ECGROUPNOTEXIST;
+                       break;
                default:
-                       return ECGROUPNOTALLOWED;
+                       ret = ECGROUPNOTALLOWED;

nitpick - I prefer a break at the end of my "default" case, but
I'm not sure what libcgroup's convention is.

                }
+               goto err;
        }
        ret = fprintf(tasks, "%d", tid);
        if (ret < 0) {
@@ -1406,7 +1409,8 @@ static int __cgroup_attach_task_pid(char *path, pid_t tid)
  err:
        cgroup_warn("Warning: cannot write tid %d to %s:%s\n",
                        tid, path, strerror(errno));
-       fclose(tasks);
+       if (tasks)
+               fclose(tasks);
        return ret;
  }



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to