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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 22 Jun 2005 23:15:56 -0700
Gerrit Huizenga <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux