All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasily Averin <vvs@virtuozzo.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH] ethtool: remove extra checks
Date: Sat, 6 Jun 2020 15:49:05 +0300	[thread overview]
Message-ID: <6d90f9b2-9bdd-d813-ef4e-ed0a7d1acaf2@virtuozzo.com> (raw)

Found by smatch:
net/ethtool/linkmodes.c:356 ethnl_set_linkmodes() warn:
 variable dereferenced before check 'info' (see line 332)
net/ethtool/linkinfo.c:143 ethnl_set_linkinfo() warn:
 variable dereferenced before check 'info' (see line 119

In both cases non-zero 'info' is always provided by caller.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 net/ethtool/linkinfo.c  | 3 +--
 net/ethtool/linkmodes.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/ethtool/linkinfo.c b/net/ethtool/linkinfo.c
index 677068d..5eaf173 100644
--- a/net/ethtool/linkinfo.c
+++ b/net/ethtool/linkinfo.c
@@ -140,8 +140,7 @@ int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info)
 
 	ret = __ethtool_get_link_ksettings(dev, &ksettings);
 	if (ret < 0) {
-		if (info)
-			GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
+		GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
 		goto out_ops;
 	}
 	lsettings = &ksettings.base;
diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
index 452608c..b759133 100644
--- a/net/ethtool/linkmodes.c
+++ b/net/ethtool/linkmodes.c
@@ -353,8 +353,7 @@ int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info)
 
 	ret = __ethtool_get_link_ksettings(dev, &ksettings);
 	if (ret < 0) {
-		if (info)
-			GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
+		GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
 		goto out_ops;
 	}
 
-- 
1.8.3.1


             reply	other threads:[~2020-06-06 12:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-06 12:49 Vasily Averin [this message]
2020-06-06 13:48 ` [PATCH] ethtool: remove extra checks Michal Kubecek

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=6d90f9b2-9bdd-d813-ef4e-ed0a7d1acaf2@virtuozzo.com \
    --to=vvs@virtuozzo.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.