Re: [ckrm-tech] [patch 04/38] CKRM e18: Resource Control FileSystem (rcfs)

From: KUROSAWA Takahiro
Date: Mon Jun 27 2005 - 02:58:03 EST


Hi,

On Wed, 22 Jun 2005 23:15:56 -0700
Gerrit Huizenga <gh@xxxxxxxxxx> wrote:

> Index: linux-2.6.12-ckrm1/fs/rcfs/magic.c

> +static ssize_t
> +magic_write(struct file *file, const char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + struct rcfs_inode_info *ri =
> + rcfs_get_inode_info(file->f_dentry->d_parent->d_inode);

> + done = magic_parse(ri->mfdentry->d_name.name,
> + optbuf, &resname, &otherstr);

I've got kernel oops (NULL pointer dereference) when writing
"res=cpu,mode=enabled" to /rcfs/taskclass/config. ri->mfdentry
has been NULL.
The 1st argument of magic_parse() should not be anything of
the class directory but the name of the written file itself.

The following patch fixes the problem for me:

--- fs/rcfs/magic.c 2005/06/27 05:42:47 1.1
+++ fs/rcfs/magic.c 2005/06/27 07:23:57
@@ -181,23 +181,23 @@ magic_write(struct file *file, const cha
}
__copy_from_user(optbuf, buf, count);
mkvalidstr(optbuf);
- done = magic_parse(ri->mfdentry->d_name.name,
+ done = magic_parse(file->f_dentry->d_name.name,
optbuf, &resname, &otherstr);
if (!done) {
printk(KERN_ERR "Error parsing data written to %s\n",
- ri->mfdentry->d_name.name);
+ file->f_dentry->d_name.name);
goto out;
}
- if (!strcmp(ri->mfdentry->d_name.name, RCFS_CONFIG_NAME)) {
+ if (!strcmp(file->f_dentry->d_name.name, RCFS_CONFIG_NAME)) {
func = core->classtype->set_config;
- } else if (!strcmp(ri->mfdentry->d_name.name, RCFS_STATS_NAME)) {
+ } else if (!strcmp(file->f_dentry->d_name.name, RCFS_STATS_NAME)) {
func = core->classtype->reset_stats;
}
if (func) {
rc = func(core, resname, otherstr);
if (rc) {
- printk(KERN_ERR "magic_write: %s: error\n",
- ri->mfdentry->d_name.name);
+ printk(KERN_ERR "magic_write: %s: error %d\n",
+ file->f_dentry->d_name.name, rc);
}
}
out:
-
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/