public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yan-Hsuan Chuang <tony0620emma@gmail.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
	Tzu-En Huang <tehuang@realtek.com>,
	linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page()
Date: Tue, 16 Feb 2021 22:43:43 +0300	[thread overview]
Message-ID: <YCwgb/4F4Y+tyE56@mwanda> (raw)

The sscanf() function returns either 0 or 1 here.  It doesn't return
error codes.  We should return -EINVAL if the string is invalid.

Fixes: c376c1fc87b7 ("rtw88: add h2c command in debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/realtek/rtw88/debug.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
index 948cb79050ea..99be7fcb5d71 100644
--- a/drivers/net/wireless/realtek/rtw88/debug.c
+++ b/drivers/net/wireless/realtek/rtw88/debug.c
@@ -262,15 +262,12 @@ static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	char tmp[32 + 1];
 	u32 offset, page_num;
-	int num;
 
 	rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
 
-	num = sscanf(tmp, "%d %d", &offset, &page_num);
-
-	if (num != 2) {
+	if (sscanf(tmp, "%d %d", &offset, &page_num) != 2) {
 		rtw_warn(rtwdev, "invalid arguments\n");
-		return num;
+		return -EINVAL;
 	}
 
 	debugfs_priv->rsvd_page.page_offset = offset;
-- 
2.30.0


             reply	other threads:[~2021-02-16 19:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 19:43 Dan Carpenter [this message]
2021-03-15  8:08 ` [PATCH] rtw88: Fix an error code in rtw_debugfs_set_rsvd_page() Kalle Valo
     [not found] ` <20210315080817.A3975C43461@smtp.codeaurora.org>
2021-03-15  9:11   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YCwgb/4F4Y+tyE56@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tehuang@realtek.com \
    --cc=tony0620emma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox