[PATCH RESEND v2 11/23] sparc: led: let procfs copy in writes
From: Christian Brauner
Date: Wed Nov 04 2026 - 15:36:46 EST
Implement ->proc_write_buf() so procfs copies in what is written to
/proc/led before it pins the entry, and parse the command from that
copy. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL now.
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
arch/sparc/kernel/led.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c
index 0f7376b51a04..1f244e394207 100644
--- a/arch/sparc/kernel/led.c
+++ b/arch/sparc/kernel/led.c
@@ -60,18 +60,14 @@ static int led_proc_show(struct seq_file *m, void *v)
return 0;
}
-static ssize_t led_proc_write(struct file *file, const char __user *buffer,
+static ssize_t led_proc_write(struct file *file, char *buf,
size_t count, loff_t *ppos)
{
size_t len = count;
- char *buf = NULL;
if (count > LED_MAX_LENGTH)
count = LED_MAX_LENGTH;
-
- buf = memdup_user_nul(buffer, count);
- if (IS_ERR(buf))
- return PTR_ERR(buf);
+ buf[count] = '\0';
/* work around \n when echo'ing into proc */
if (count > 0 && buf[count - 1] == '\n')
@@ -96,14 +92,12 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer,
auxio_set_led(AUXIO_LED_OFF);
}
- kfree(buf);
-
return len;
}
static const struct proc_ops led_proc_ops = {
.proc_show = led_proc_show,
- .proc_write = led_proc_write,
+ .proc_write_buf = led_proc_write,
};
#endif
--
2.53.0