mwifiex_regrdwr_read() can issue a register write for a debugfs request. It overwrites the write result with the buffer-copy result, so userspace receives a normal response even if the firmware command failed. Return through the existing buffer cleanup path on a write error, before copying a success response or advancing the file position. Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver") Signed-off-by: Zhu Jun --- drivers/net/wireless/marvell/mwifiex/debugfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c index 573768b6ad91..6cb3cf5706c0 100644 --- a/drivers/net/wireless/marvell/mwifiex/debugfs.c +++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c @@ -470,6 +470,8 @@ mwifiex_regrdwr_read(struct file *file, char __user *ubuf, if (saved_reg_value != UINT_MAX) { ret = mwifiex_reg_write(priv, saved_reg_type, saved_reg_offset, saved_reg_value); + if (ret) + goto done; pos += snprintf(buf, PAGE_SIZE, "%u 0x%x 0x%x\n", saved_reg_type, saved_reg_offset, -- 2.51.0