Re: [ckrm-tech] [PATCH 6/6] Resource Groups over generic containers

From: Balbir Singh
Date: Sun Nov 05 2006 - 16:16:45 EST


Hi, Paul,

I've just started playing with the new patchset and found a few issues.

menage@xxxxxxxxxx wrote:
> +ssize_t res_group_file_write(struct container *cont,
> + struct cftype *cft,
> + struct file *file,
> + const char __user *userbuf,
> + size_t nbytes, loff_t *ppos)
> +{
> + struct res_group_cft *rgcft = container_of(cft, struct res_group_cft, cft);
> + struct res_controller *ctlr = rgcft->ctlr;
> +
> + if (nbytes >= PAGE_SIZE)
> + return -E2BIG;
> +
> + char *buf;
> + ssize_t retval;
> + int filetype = cft->private;
> +
> + buf = kmalloc(nbytes + 1, GFP_USER);

This should be kmalloc(nbytes), an echo ".." has a "\n" associated
with it.

> + if (!buf) return -ENOMEM;
> + if (copy_from_user(buf, userbuf, nbytes)) {
> + retval = -EFAULT;
> + goto out1;
> + }
> + buf[nbytes] = 0; /* nul-terminate */
> +

this should be buf[nbytes - 1]



--

Balbir Singh,
Linux Technology Center,
IBM Software Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/