[Devel] [PATCH rh7 4/6] ub: rework connection between ub and mem/blkio cgroups

Vladimir Davydov vdavydov at parallels.com
Mon Jun 8 00:48:40 PDT 2015


On Mon, Jun 08, 2015 at 10:16:04AM +0300, Cyrill Gorcunov wrote:
> On Sun, Jun 07, 2015 at 02:57:16PM +0300, Vladimir Davydov wrote:
> > +static ssize_t ub_cgroup_read(struct cgroup *cg, struct cftype *cft,
> > +			      struct file *file, char __user *buf,
> > +			      size_t nbytes, loff_t *ppos)
> > +{
> > +	struct user_beancounter *ub = cgroup_ub(cg);
> > +	struct cgroup_subsys_state *bound_css;
> > +	char *path;
> > +	int len;
> > +	ssize_t ret;
> > +
> > +	bound_css = __ub_get_css(ub, cft->private);
> > +
> > +	ret = -ENOMEM;
> > +	path = kmalloc(PATH_MAX + 1, GFP_KERNEL);
> 
> PATH_MAX + 2, other in series looks good, thank you!

Why +2?

> Reviewed-by: Cyrill Gorcunov <gorcunov at openvz.org>
> 
> > +	if (!path)
> > +		goto out;
> > +	ret = cgroup_path(bound_css->cgroup, path, PATH_MAX);
> > +	if (!ret) {
> > +		len = strlen(path);
> > +		path[len++] = '\n';
> > +		path[len] = '\0';
> > +		ret = simple_read_from_buffer(buf, nbytes, ppos, path, len);
> > +	}
> > +	kfree(path);
> > +out:
> > +	css_put(bound_css);
> > +	return ret;
> > +}
> 



More information about the Devel mailing list