ethtool: linkinfo: remove an unnecessary NULL check
Subsystems (4)
PATCH 1/1 ethtool: linkinfo: remove an unnecessary NULL check
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.
--- net/ethtool/linkinfo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ethtool/linkinfo.c +1 -2
@@ -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;
Signature · 1 line
2.26.2
Quoted 9 lines · Dan Carpenter
This code generates a Smatch warning:
net/ethtool/linkinfo.c:143ethnl_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 <[email protected]>
The same useless check is also in ethnl_set_linkmodes(), I'll send a patch for that one.
Michal
Quoted 21 lines
--- net/ethtool/linkinfo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/ethtool/linkinfo.c +1
-2@@ -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;Signature · 1 line
2.26.2
From: Dan Carpenter <[email protected]>
Date: Fri, 5 Jun 2020 14:04:13 +0300
Quoted 9 lines
This code generates a Smatch warning:
net/ethtool/linkinfo.c:143ethnl_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 <[email protected]>
Applied.