[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5bd5bfa.4758.1880b4c8bb2.Coremail.iccccc@hust.edu.cn>
Date: Thu, 11 May 2023 22:52:25 +0800 (GMT+08:00)
From: 刘浩毅 <iccccc@...t.edu.cn>
To: "david s. miller" <davem@...emloft.net>,
"david ahern" <dsahern@...nel.org>,
"eric dumazet" <edumazet@...gle.com>,
"jakub kicinski" <kuba@...nel.org>,
"paolo abeni" <pabeni@...hat.com>
Cc: hust-os-kernel-patches@...glegroups.com, yalongz@...t.edu.cn,
error27@...il.com, "dongliang mu" <dzm91@...t.edu.cn>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH net-next v2] net/ipv6: silence 'passing zero to ERR_PTR()'
warning
> -----原始邮件-----
> 发件人: "Haoyi Liu" <iccccc@...t.edu.cn>
> 发送时间: 2023-04-13 18:10:05 (星期四)
> 收件人: "David S. Miller" <davem@...emloft.net>, "David Ahern" <dsahern@...nel.org>, "Eric Dumazet" <edumazet@...gle.com>, "Jakub Kicinski" <kuba@...nel.org>, "Paolo Abeni" <pabeni@...hat.com>
> 抄送: hust-os-kernel-patches@...glegroups.com, yalongz@...t.edu.cn, error27@...il.com, "Haoyi Liu" <iccccc@...t.edu.cn>, "Dongliang Mu" <dzm91@...t.edu.cn>, netdev@...r.kernel.org, linux-kernel@...r.kernel.org
> 主题: [PATCH net-next v2] net/ipv6: silence 'passing zero to ERR_PTR()' warning
>
> Smatch complains that if xfrm_lookup() returns NULL then this does a
> weird thing with "err":
>
> net/ ipv6/ icmp.c:411 icmpv6_route_lookup()
> warn: passing zero to ERR_PTR()
>
> Merge conditional paths and remove unnecessary 'else'. No functional
> change.
>
> Signed-off-by: Haoyi Liu <iccccc@...t.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
> ---
> v1->v2: Remove unnecessary 'else'.
> The issue is found by static analysis, and the patch is remains untested.
> ---
> net/ipv6/icmp.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
> index 1f53f2a74480..a12eef11c7ee 100644
> --- a/net/ipv6/icmp.c
> +++ b/net/ipv6/icmp.c
> @@ -393,17 +393,12 @@ static struct dst_entry *icmpv6_route_lookup(struct net *net,
> goto relookup_failed;
>
> dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_ICMP);
> - if (!IS_ERR(dst2)) {
> - dst_release(dst);
> - dst = dst2;
> - } else {
> - err = PTR_ERR(dst2);
> - if (err == -EPERM) {
> - dst_release(dst);
> - return dst2;
> - } else
> - goto relookup_failed;
> - }
> + err = PTR_ERR_OR_ZERO(dst2);
> + if (err && err != -EPERM)
> + goto relookup_failed;
> +
> + dst_release(dst);
> + return dst2; /* returns success or ERR_PTR(-EPERM) */
>
> relookup_failed:
> if (dst)
> --
> 2.40.0
ping?
Powered by blists - more mailing lists