From: Denis Plotnikov <den-plotnikov@yandex-team.ru>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, rajur@chelsio.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, den-plotnikov@yandex-team.ru
Subject: [PATCH] cxgb4: do conversion after string check
Date: Thu, 30 Mar 2023 18:47:03 +0300 [thread overview]
Message-ID: <20230330154703.36958-1-den-plotnikov@yandex-team.ru> (raw)
Static code analyzer complains to uncheck return value.
Indeed, the return value of kstrtouint "must be checked"
as the comment says.
Moreover, it looks like the string conversion should be
after "end of string" or "new line" check.
This patch fixes these issues.
Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 14e0d989c3ba5..a8d3616630cc6 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -1576,9 +1576,11 @@ inval: count = -EINVAL;
}
if (*word == '@') {
end = (char *)word + 1;
- ret = kstrtouint(end, 10, &j);
if (*end && *end != '\n')
goto inval;
+ ret = kstrtouint(end, 10, &j);
+ if (ret)
+ goto inval;
if (j & 7) /* doesn't start at multiple of 8 */
goto inval;
j /= 8;
--
2.25.1
next reply other threads:[~2023-03-30 15:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 15:47 Denis Plotnikov [this message]
2023-03-30 19:52 ` Simon Horman
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=20230330154703.36958-1-den-plotnikov@yandex-team.ru \
--to=den-plotnikov@yandex-team.ru \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rajur@chelsio.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
all inboxes | Powered by JetHome®