All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Vasily Averin <vvs@virtuozzo.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH] ethtool: remove extra checks
Date: Sat, 6 Jun 2020 15:48:38 +0200	[thread overview]
Message-ID: <20200606134838.buk2ior2oqdnboqz@lion.mk-sys.cz> (raw)
In-Reply-To: <6d90f9b2-9bdd-d813-ef4e-ed0a7d1acaf2@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]

On Sat, Jun 06, 2020 at 03:49:05PM +0300, Vasily Averin wrote:
> 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;

This change is already in net tree as commit 178f67b1288b ("ethtool:
linkinfo: remove an unnecessary NULL check").

> 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;
>  	}
>  

For this part, 

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>

Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-06-06 13:48 UTC|newest]

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

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=20200606134838.buk2ior2oqdnboqz@lion.mk-sys.cz \
    --to=mkubecek@suse.cz \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vvs@virtuozzo.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 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.