Skip to contentSkip to conversation

Sysfs not handling show errors

PATCH Applied Rusty Lynch 2 participants 2 messages Feb 12, 2003 – Feb 13, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Sysfs not handling show errors

Attempting to cat a sysfs file that returns an error will result in an endless dump of garbage to the screen because the result of the specific show operation was being saved to a size_t (unsigned) and then later checked for a negative value.

Here is a trivial patch to fix the error.

--rustyl

sysfs/inode.c renamed from sysfs/inode.c.orig +1 -1
@@ -210,7 +210,7 @@
 	struct kobject * kobj = file->f_dentry->d_parent->d_fsdata;
 	struct sysfs_ops * ops = buffer->ops;
 	int ret = 0;
-	size_t count;
+	ssize_t count;
 
 	if (!buffer->page)
 		buffer->page = (char *) __get_free_page(GFP_KERNEL);
#1 lore raw
Quoted 6 lines · Rusty Lynch

Attempting to cat a sysfs file that returns an error will result in an endless dump of garbage to the screen because the result of the specific show operation was being saved to a size_t (unsigned) and then later checked for a negative value.

Here is a trivial patch to fix the error.

Thanks, applied.

-pat