From: Li Zefan Date: Fri, 14 Feb 2014 08:56:04 +0000 (+0800) Subject: cgroup: deal with dummp_top in cgroup_name() and cgroup_path() X-Git-Tag: next-20140306~19^2~7^2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cc045e3952175e84c38dad22dea14465b9fc8fb5;p=karo-tx-linux.git cgroup: deal with dummp_top in cgroup_name() and cgroup_path() My kernel fails to boot, because blkcg calls cgroup_path() while cgroupfs is not mounted. Fix both cgroup_name() and cgroup_path(). Signed-off-by: Li Zefan Signed-off-by: Tejun Heo --- diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index ef0b3af0e61c..8c283a910b91 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -487,13 +487,21 @@ struct cgroup_subsys_state *seq_css(struct seq_file *seq); static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen) { - return kernfs_name(cgrp->kn, buf, buflen); + /* dummy_top doesn't have a kn associated */ + if (cgrp->kn) + return kernfs_name(cgrp->kn, buf, buflen); + else + return strlcpy(buf, "/", buflen); } static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf, size_t buflen) { - return kernfs_path(cgrp->kn, buf, buflen); + /* dummy_top doesn't have a kn associated */ + if (cgrp->kn) + return kernfs_path(cgrp->kn, buf, buflen); + strlcpy(buf, "/", buflen); + return (buflen <= 2) ? NULL : buf; } static inline void pr_cont_cgroup_name(struct cgroup *cgrp)