Fix a resource leaks reported by Coverity tool:
CID 258302 (#1 of 1): Resource leak (RESOURCE_LEAK). leaked_storage:
Variable dir going out of scope leaks the storage it points to
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
continue;
ret = cgroup_fill_cgc(ctrl_dir, cg, cgc, i);
- if (ret == ECGFAIL) {
- closedir(dir);
+ if (ret == ECGFAIL)
goto out;
- }
if (cgc->index > 0) {
cgc->values[cgc->index - 1]->dirty = false;
}
}
- closedir(dir);
-
out:
+ if (dir)
+ closedir(dir);
+
pthread_rwlock_unlock(&cg_mount_table_lock);
return ret;