linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check
@ 2020-07-31  4:58 Gaurav Singh
  2020-07-31 13:54 ` Michal Kubecek
  2020-08-03 22:12 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Gaurav Singh @ 2020-07-31  4:58 UTC (permalink / raw)
  To: gaurav1086, David S. Miller, Jakub Kicinski, Michal Kubecek,
	Florian Fainelli, Andrew Lunn, Oleksij Rempel, YueHaibing,
	Aya Levin, open list:NETWORKING [GENERAL],
	open list

info cannot be NULL here since its being accessed earlier
in the function: nlmsg_parse(info->nlhdr...). Remove this
redundant NULL check.

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 net/ethtool/linkmodes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
index fd4f3e58c6f6..b595d87fa880 100644
--- a/net/ethtool/linkmodes.c
+++ b/net/ethtool/linkmodes.c
@@ -406,8 +406,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;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check
  2020-07-31  4:58 [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check Gaurav Singh
@ 2020-07-31 13:54 ` Michal Kubecek
  2020-08-03 22:12 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Kubecek @ 2020-07-31 13:54 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: David S. Miller, Jakub Kicinski, Florian Fainelli, Andrew Lunn,
	Oleksij Rempel, YueHaibing, Aya Levin,
	open list:NETWORKING [GENERAL],
	open list

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

On Fri, Jul 31, 2020 at 12:58:44AM -0400, Gaurav Singh wrote:
> info cannot be NULL here since its being accessed earlier
> in the function: nlmsg_parse(info->nlhdr...). Remove this
> redundant NULL check.

This is what the static checker tells you but it could still mean the
other place is missing the check. The actual reason why this check is
superfluous is that the function is only used as ->doit() handler which
is never called with null info.

> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

The subject should rather start with "ethtool: " (instead of "[net/ethtool] ").

For the change itself:

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

Michal

> ---
>  net/ethtool/linkmodes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
> index fd4f3e58c6f6..b595d87fa880 100644
> --- a/net/ethtool/linkmodes.c
> +++ b/net/ethtool/linkmodes.c
> @@ -406,8 +406,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;
>  	}
>  
> -- 
> 2.17.1
> 

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check
  2020-07-31  4:58 [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check Gaurav Singh
  2020-07-31 13:54 ` Michal Kubecek
@ 2020-08-03 22:12 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-08-03 22:12 UTC (permalink / raw)
  To: gaurav1086
  Cc: kuba, mkubecek, f.fainelli, andrew, linux, yuehaibing, ayal,
	netdev, linux-kernel

From: Gaurav Singh <gaurav1086@gmail.com>
Date: Fri, 31 Jul 2020 00:58:44 -0400

> info cannot be NULL here since its being accessed earlier
> in the function: nlmsg_parse(info->nlhdr...). Remove this
> redundant NULL check.
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-03 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31  4:58 [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check Gaurav Singh
2020-07-31 13:54 ` Michal Kubecek
2020-08-03 22:12 ` 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).