Implement ->proc_write_buf() so procfs copies in what is written before
it pins the entry, and take the device name from that copy. Writes
larger than PAGE_SIZE - 1 bytes fail with -EINVAL now.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
drivers/acpi/proc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index b8a0bd4580e0..feb8283fd855 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -86,7 +86,7 @@ static void physical_device_enable_wakeup(struct acpi_device *adev)
static ssize_t
acpi_system_write_wakeup_device(struct file *file,
- const char __user * buffer,
+ char *buffer,
size_t count, loff_t * ppos)
{
struct acpi_device *dev, *tmp;@@ -96,8 +96,7 @@ acpi_system_write_wakeup_device(struct file *file,
if (count > 4)
count = 4;
- if (copy_from_user(strbuf, buffer, count))
- return -EFAULT;
+ memcpy(strbuf, buffer, count);
strbuf[count] = '\0';
sscanf(strbuf, "%s", str);
@@ -123,7 +122,7 @@ acpi_system_write_wakeup_device(struct file *file,
static const struct proc_ops acpi_system_wakeup_device_proc_ops = {
.proc_show = acpi_system_wakeup_device_seq_show,
- .proc_write = acpi_system_write_wakeup_device,
+ .proc_write_buf = acpi_system_write_wakeup_device,
};
void __init acpi_sleep_proc_init(void)
--
2.53.0