Skip to contentSkip to conversation

Input: serio_raw: Fix uninitialized variable 'written'

PATCH In review Colin Ian King 2 participants 2 messages Oct 21, 2024

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

PATCH 1/1 Input: serio_raw: Fix uninitialized variable 'written'

The variable written is not initialized and subsequent increments of the variable are using an uninitialized value. Fix this by initializating it at the start of the function.

Fixes 5b53a9d40c4f ("Input: serio_raw - use guard notation for locks and other resources")
---
 drivers/input/serio/serio_raw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/serio/serio_raw.c +1 -1
index e058fef07f57..4d6395088986 100644
@@ -185,7 +185,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 {
 	struct serio_raw_client *client = file->private_data;
 	struct serio_raw *serio_raw = client->serio_raw;
-	int written;
+	int written = 0;
 	unsigned char c;
 
 	scoped_guard(mutex_intr, &serio_raw_mutex) {
Signature · 1 line
2.39.5
maintainer
#1 lore raw

Hi Colin,

Quoted 3 lines · Colin Ian King

The variable written is not initialized and subsequent increments of the variable are using an uninitialized value. Fix this by initializating it at the start of the function.

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

Quoted 23 lines
Fixes 5b53a9d40c4f ("Input: serio_raw - use guard notation for locks and other resources")
---
 drivers/input/serio/serio_raw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/serio/serio_raw.c +1 -1
index e058fef07f57..4d6395088986 100644
@@ -185,7 +185,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 {
 	struct serio_raw_client *client = file->private_data;
 	struct serio_raw *serio_raw = client->serio_raw;
-	int written;
+	int written = 0;
 	unsigned char c;
 
 	scoped_guard(mutex_intr, &serio_raw_mutex) {
Signature · 1 line
2.39.5
Signature · 1 line
Dmitry