diff mbox series

thunderbolt: debugfs: Fix uninitialized return in counters_write()

Message ID 20200910100805.GB79916@mwanda (mailing list archive)
State Accepted
Commit 77e4907fa620af102f4571d4edb0dcc95b4fa083
Headers show
Series thunderbolt: debugfs: Fix uninitialized return in counters_write() | expand

Commit Message

Dan Carpenter Sept. 10, 2020, 10:08 a.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/thunderbolt/debugfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mika Westerberg Sept. 10, 2020, 4:42 p.m. UTC | #1
On Thu, Sep 10, 2020 at 01:08:05PM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index fdfe6e4afbfe..3680b2784ea1 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -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);