lkml.org 
[lkml]   [2013]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] cgroup: implement task_cgroup_path_from_hierarchy()
On 2013/4/15 11:46, Tejun Heo wrote:
> On Mon, Apr 15, 2013 at 11:43:15AM +0800, Li Zefan wrote:
>>> +int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id,
>>> + char *buf, size_t buflen)
>>> +{
>>> + struct cgroupfs_root *root;
>>> + struct cgroup *cgrp = NULL;
>>> + int ret = -ENOENT;
>>> +
>>> + mutex_lock(&cgroup_mutex);
>>> +
>>> + root = idr_find(&cgroup_hierarchy_idr, hierarchy_id);
>>> + if (root) {
>>> + cgrp = task_cgroup_from_root(task, root);
>>
>> task_cgroup_from_root() will never return NULL, and there's a BUG_ON(!res) in it.
>
> @hierarchy_id may come from userland, so we probably should update
> task_cgroup_from_root() to return NULL if the id is invalid. Will add
> a patch.
>

But if id is invalid, idr_find() will return NULL. As long as root is not NULL,
task_cgroup_from_root() will always return a valid cgroup.



\
 
 \ /
  Last update: 2013-04-15 06:21    [W:0.046 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site