* [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check
@ 2020-06-05 11:04 Dan Carpenter
2020-06-05 12:31 ` Michal Kubecek
2020-06-05 20:11 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-06-05 11:04 UTC (permalink / raw)
To: David S. Miller
Cc: Jakub Kicinski, Michal Kubecek, Florian Fainelli, Andrew Lunn,
netdev, kernel-janitors
This code generates a Smatch warning:
net/ethtool/linkinfo.c:143 ethnl_set_linkinfo()
warn: variable dereferenced before check 'info' (see line 119)
Fortunately, the "info" pointer is never NULL so the check can be
removed.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/ethtool/linkinfo.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/ethtool/linkinfo.c b/net/ethtool/linkinfo.c
index 677068deb68c0..5eaf173eaaca5 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;
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check
2020-06-05 11:04 [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check Dan Carpenter
@ 2020-06-05 12:31 ` Michal Kubecek
2020-06-05 20:11 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Michal Kubecek @ 2020-06-05 12:31 UTC (permalink / raw)
To: netdev
Cc: Dan Carpenter, David S. Miller, Jakub Kicinski, Florian Fainelli,
Andrew Lunn, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]
On Fri, Jun 05, 2020 at 02:04:13PM +0300, Dan Carpenter wrote:
> This code generates a Smatch warning:
>
> net/ethtool/linkinfo.c:143 ethnl_set_linkinfo()
> warn: variable dereferenced before check 'info' (see line 119)
>
> Fortunately, the "info" pointer is never NULL so the check can be
> removed.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
The same useless check is also in ethnl_set_linkmodes(), I'll send
a patch for that one.
Michal
> ---
> net/ethtool/linkinfo.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/ethtool/linkinfo.c b/net/ethtool/linkinfo.c
> index 677068deb68c0..5eaf173eaaca5 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;
> --
> 2.26.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check
2020-06-05 11:04 [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check Dan Carpenter
2020-06-05 12:31 ` Michal Kubecek
@ 2020-06-05 20:11 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-05 20:11 UTC (permalink / raw)
To: dan.carpenter; +Cc: kuba, mkubecek, f.fainelli, andrew, netdev, kernel-janitors
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 5 Jun 2020 14:04:13 +0300
> This code generates a Smatch warning:
>
> net/ethtool/linkinfo.c:143 ethnl_set_linkinfo()
> warn: variable dereferenced before check 'info' (see line 119)
>
> Fortunately, the "info" pointer is never NULL so the check can be
> removed.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-05 20:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 11:04 [PATCH net] ethtool: linkinfo: remove an unnecessary NULL check Dan Carpenter
2020-06-05 12:31 ` Michal Kubecek
2020-06-05 20:11 ` David Miller
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).