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

KUROSAWA Takahiro
2005-06-27T07:56:54Z

Hi,

On Wed, 22 Jun 2005 23:15:56 -0700
Gerrit Huizenga <gh@us.ibm.com> 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);
}
}