2021-12-30 06:31:54

by CGEL

[permalink] [raw]
Subject: [PATCH linux] netfilter: Remove unnecessary ret assignment

From: luo penghao <[email protected]>

Regardless of whether the subsequent (copy_to_user(user, &info, *len) != 0)
holds, the value of ret will be assigned a new value.

The clang_analyzer complains as follows:

net/ipv6/netfilter/ip6_tables.c:

Value stored to 'ret' is never read

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: luo penghao <[email protected]>
---
net/ipv6/netfilter/ip6_tables.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index a579ea1..92b90a2 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -986,7 +986,7 @@ static int get_info(struct net *net, void __user *user, const int *len)
struct xt_table_info tmp;

if (in_compat_syscall()) {
- ret = compat_table_info(private, &tmp);
+ compat_table_info(private, &tmp);
xt_compat_flush_offsets(AF_INET6);
private = &tmp;
}
--
2.15.2




2021-12-30 12:12:41

by Florian Westphal

[permalink] [raw]
Subject: Re: [PATCH linux] netfilter: Remove unnecessary ret assignment

[email protected] <[email protected]> wrote:
> From: luo penghao <[email protected]>
>
> Regardless of whether the subsequent (copy_to_user(user, &info, *len) != 0)
> holds, the value of ret will be assigned a new value.
>
> The clang_analyzer complains as follows:
>
> net/ipv6/netfilter/ip6_tables.c:
>
> Value stored to 'ret' is never read

Please fix this properly:

1. consider adding error unwinding instead.
2. net/ipv4/netfilter/ip_tables.c has same construct