Commit f81ab470 authored by Patrick Mochel's avatar Patrick Mochel

sysfs: Fix binary file handling.

From Rusty Lynch:

* makes sysfs cleanup the buffer->data allocated by the attribute write
functions
* fixes a bug that causes the kernel to oops when somebody attempts to
write to the file.
parent 1cdccc69
......@@ -50,6 +50,10 @@ read(struct file * file, char * userbuf, size_t count, loff_t * off)
ret = count;
}
Done:
if (buffer && buffer->data) {
kfree(buffer->data);
buffer->data = NULL;
}
return ret;
}
......@@ -66,7 +70,7 @@ int alloc_buf_data(struct sysfs_bin_buffer * buffer)
static int fill_write(struct file * file, const char * userbuf,
struct sysfs_bin_buffer * buffer)
{
return copy_from_user(buffer,userbuf,buffer->count) ?
return copy_from_user(buffer->data,userbuf,buffer->count) ?
-EFAULT : 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment