From: Colin King <colin.king@canonical.com>
To: Tom Lendacky <thomas.lendacky@amd.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] amd-xgbe: fix unsigned comparison against less than zero
Date: Tue, 15 Nov 2016 12:18:42 +0000 [thread overview]
Message-ID: <20161115121842.5774-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Comparing unsigned int ret to less than zero for an error status
check is never true. Fix this by making ret a signed int. Reduce
scope of ret too.
Found with static analysis by CoverityScan, CID 1377750
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 4ba4332..168507e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -2346,7 +2346,7 @@ static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
{
struct xgbe_phy_data *phy_data = pdata->phy_data;
- unsigned int ret, reg;
+ unsigned int reg;
*an_restart = 0;
@@ -2365,7 +2365,8 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
if (phy_data->phydev) {
/* Check external PHY */
- ret = phy_read_status(phy_data->phydev);
+ int ret = phy_read_status(phy_data->phydev);
+
if (ret < 0)
return 0;
--
2.10.2
next reply other threads:[~2016-11-15 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 12:18 Colin King [this message]
2016-11-15 14:09 ` [PATCH] amd-xgbe: fix unsigned comparison against less than zero Tom Lendacky
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=20161115121842.5774-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=thomas.lendacky@amd.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;
as well as URLs for NNTP newsgroup(s).