2020-07-31 05:02:20

by Gaurav Singh

[permalink] [raw]
Subject: [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check

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 <[email protected]>
---
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


2020-07-31 22:47:12

by Michal Kubecek

[permalink] [raw]
Subject: Re: [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check

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 <[email protected]>

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

For the change itself:

Reviewed-by: Michal Kubecek <[email protected]>

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
>


Attachments:
(No filename) (1.31 kB)
signature.asc (499.00 B)
Download all attachments

2020-08-03 22:14:59

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] [net/ethtool] ethnl_set_linkmodes: remove redundant null check

From: Gaurav Singh <[email protected]>
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 <[email protected]>

Applied, thank you.