Re: [BUG 2.6.7-mm1] sysfs - possible bug

From: Andrew Morton
Date: Sat Jun 26 2004 - 21:12:34 EST


Luca Risolia <luca.risolia@xxxxxxxxxxxxxxx> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> This code causes some problems:
>
> static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
> {
> return -EIO;
> }
> static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, sn9c102_show_i2c_val, sn9c102_store_i2c_val);

Indeed it does.

> kernel BUG at fs/sysfs/file.c:93!

BUG_ON(count > PAGE_SIZE);

isn't right, because PAGE_SIZE is unsigned.

I'll send the below fix to Linus.

--- 25/fs/sysfs/file.c~sysfs-fill_read_buffer-fix 2004-06-26 19:03:11.821870464 -0700
+++ 25-akpm/fs/sysfs/file.c 2004-06-26 19:03:20.119609016 -0700
@@ -83,7 +83,7 @@ static int fill_read_buffer(struct file
return -ENOMEM;

count = ops->show(kobj,attr,buffer->page);
- BUG_ON(count > PAGE_SIZE);
+ BUG_ON(count > (ssize_t)PAGE_SIZE);
if (count >= 0)
buffer->count = count;
else
_

-
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/