Skip to contentSkip to conversation

Input: serio_raw - initialize serio_raw_write() the return code

PATCH In review Arnd Bergmann 2 participants 2 messages Oct 21, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: serio_raw - initialize serio_raw_write() the return code

From: Arnd Bergmann <[email protected]>

The number of bytes returned from the write function is now undefined:

drivers/input/serio/serio_raw.c:204:12: error: variable 'written' is uninitialized when used here [-Werror,-Wuninitialized]
204 | return written ?: -EIO;
| ^~~~~~~

---
 drivers/input/serio/serio_raw.c | 1 +
 1 file changed, 1 insertion(+)
drivers/input/serio/serio_raw.c +1 -0
index e058fef07f57..55fe77d04089 100644
@@ -195,6 +195,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 		if (count > 32)
 			count = 32;
 
+		written = 0;
 		while (count--) {
 			if (get_user(c, buffer++))
 				return -EFAULT;
Signature · 1 line
2.39.5
maintainer
#1 lore raw

Hi Arnd,

Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The number of bytes returned from the write function is now undefined:

drivers/input/serio/serio_raw.c:204:12: error: variable 'written' is uninitialized when used here [-Werror,-Wuninitialized]
204 | return written ?: -EIO;
| ^~~~~~~

Thank you for the patch but I already have one fixing this up queued.

Quoted 26 lines
---
 drivers/input/serio/serio_raw.c | 1 +
 1 file changed, 1 insertion(+)
drivers/input/serio/serio_raw.c +1 -0
index e058fef07f57..55fe77d04089 100644
@@ -195,6 +195,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 		if (count > 32)
 			count = 32;
 
+		written = 0;
 		while (count--) {
 			if (get_user(c, buffer++))
 				return -EFAULT;
Signature · 1 line
2.39.5
Signature · 1 line
Dmitry