From db00ec5091a3ab9dd994b6366a57aa7ddfa196e5 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Sat, 9 Aug 2008 09:23:56 +0000 Subject: libcgroup: Fix segmentation fault in cgroup_init() -take2 An artifact from the time when libcgroup could not handle multiple cgroup filesystems mounted at multiple points. It is very much possible a subsystem is not mounted at that point. (FWIW, it is wrong even on a single mount point, but I am quite surprised that no one hit it yet.) V1->V2 A minor cleanup possible. Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@120 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- api.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'api.c') diff --git a/api.c b/api.c index 17e9d67..a170e63 100644 --- a/api.c +++ b/api.c @@ -193,9 +193,13 @@ int cgroup_init() if (!strcmp(ent->mnt_type, "cgroup")) { for (i = 0; controllers[i] != NULL; i++) { mntopt = hasmntopt(ent, controllers[i]); + + if (!mntopt) + continue; + mntopt = strtok_r(mntopt, ",", &strtok_buffer); - if (mntopt && - strcmp(mntopt, controllers[i]) == 0) { + + if (strcmp(mntopt, controllers[i]) == 0) { dbg("matched %s:%s\n", mntopt, controllers[i]); strcpy(cg_mount_table[found_mnt].name, -- cgit