Re: 2.6.13-rc6-mm1

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

 



This should fix it, but I'm not on a machine where I can test it. Can
you give it a try and let me know?

On 8/21/05, Benoit Boissinot <[email protected]> wrote:
> ----- Forwarded message from Benoit Boissinot <[email protected]> -----
> sorry, i forgot to reply all...
> 
> From: Benoit Boissinot <[email protected]>
> To: Jon Smirl <[email protected]>
> Subject: Re: 2.6.13-rc6-mm1
> User-Agent: Mutt/1.5.10i
> 
> On Sun, Aug 21, 2005 at 06:11:57PM -0400, Jon Smirl wrote:
> > On 8/21/05, Benoit Boissinot <[email protected]> wrote:
> > > On Sun, Aug 21, 2005 at 01:40:31PM -0400, Jon Smirl wrote:
> > > > On 8/21/05, Benoit Boissinot <[email protected]> wrote:
> > > > [snip]
> > > >
> > > > Somewhere there is a mistake in the white space processing code of the
> > > > firmware driver. Before this patch we had inconsistent handling of
> > > > whitespace and sysfs attributes. This patch forces it to be consistent
> > > > and will shake out all of the places in the drivers where it is
> > > > handled wrong. Sysfs attributes are now stripped of leading and
> > > > trailing white space before being handed to the device driver.
> > >
> > > ok, i found it. If i do echo 1, it will read '1\n', will
> > > remove the '\n' and send '1' to ops->store.
> > > Then it will re-read '\n' and send '' to ops->store.
> > > And it will loop...
> >
> > Look at the length being passed in, isn't it set to zero for the second case?
> >
> yes, it is set to zero, but the '\n' will be stripped and stay in the buffer.
> Since flush_write_buffer returns 0, ppos will not be incremented and we
> have an endless loop.
> 
> --
> powered by bash/screen/(urxvt/fvwm|linux-console)/gentoo/gnu/linux OS
> 
> ----- End forwarded message -----
> 
> --
> powered by bash/screen/(urxvt/fvwm|linux-console)/gentoo/gnu/linux OS
> -
> 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/
> 


-- 
Jon Smirl
[email protected]
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -6,6 +6,7 @@
 #include <linux/fsnotify.h>
 #include <linux/kobject.h>
 #include <linux/namei.h>
+#include <linux/ctype.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 
@@ -207,8 +208,28 @@ flush_write_buffer(struct dentry * dentr
 	struct attribute * attr = to_attr(dentry);
 	struct kobject * kobj = to_kobj(dentry->d_parent);
 	struct sysfs_ops * ops = buffer->ops;
+	int ws_count = count;
+	char *x;
 
-	return ops->store(kobj,attr,buffer->page,count);
+	/* locate trailing white space */
+	while ((count > 0) && isspace(buffer->page[count - 1]))
+		count--;
+
+	/* locate leading white space */
+	x = buffer->page;
+	if (count > 0) {
+		while (isspace(*x))
+			x++;
+		count -= (x - buffer->page);
+	}
+	/* terminate the string */
+	x[count] = '\0';
+	ws_count -= count;
+
+	if (count != 0)
+		count = ops->store(kobj, attr, x, count);
+
+	return count + ws_count;
 }
 
 

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