Skip to contentSkip to conversation

thunderbolt: debugfs: Fix uninitialized return in counters_write()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 10, 2020

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

PATCH 1/1 thunderbolt: debugfs: Fix uninitialized return in counters_write()

If the first line is in an invalid format then the "ret" value is uninitialized. We should return -EINVAL instead.

Fixes 54e418106c76 ("thunderbolt: Add debugfs interface")
---
 drivers/thunderbolt/debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thunderbolt/debugfs.c +1 -0
index fdfe6e4afbfe..3680b2784ea1 100644
@@ -231,6 +231,7 @@ static ssize_t counters_write(struct file *file, const char __user *user_buf,
 		char *line = buf;
 		u32 val, offset;
 
+		ret = -EINVAL;
 		while (parse_line(&line, &offset, &val, 1, 4)) {
 			ret = tb_port_write(port, &val, TB_CFG_COUNTERS,
 					    offset, 1);
Signature · 1 line
2.28.0
#1 lore raw
Quoted 5 lines · Dan Carpenter

If the first line is in an invalid format then the "ret" value is uninitialized. We should return -EINVAL instead.

Fixes 54e418106c76 ("thunderbolt: Add debugfs interface")

Applied, thanks!