[PATCH] cgroup:cgroup_mount: Fix uninitialized warning

Takeshi Misawa jeantsuru at gmail.com
Sat Apr 19 12:52:14 UTC 2014


This patch fixes the following warning.

kernel/cgroup.c: In function ‘cgroup_mount’:
kernel/cgroup.c:1609:13: warning: ‘root’ may be used uninitialized in this
function

Signed-off-by: Takeshi Misawa <jeantsuru at gmail.com>
---
 kernel/cgroup.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 9fcdaa7..ba03421 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1483,7 +1483,7 @@ static struct dentry *cgroup_mount(struct
file_system_type *fs_type,
                         int flags, const char *unused_dev_name,
                         void *data)
 {
-       struct cgroup_root *root;
+       struct cgroup_root *root = NULL;
        struct cgroup_sb_opts opts;
        struct dentry *dentry;
        int ret;
@@ -1604,6 +1604,11 @@ out_unlock:
        if (ret)
                return ERR_PTR(ret);

+       if (!root) {
+               if (!ret) ret = -EINVAL;
+               return ERR_PTR(ret);
+       }
+
        dentry = kernfs_mount(fs_type, flags, root->kf_root, &new_sb);
        if (IS_ERR(dentry) || !new_sb)
                cgroup_put(&root->cgrp);


More information about the Containers mailing list