Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1675133 > unrolled thread
| Started by | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| First post | 2017-06-27 00:40 +0200 |
| Last post | 2017-06-27 05:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-27 00:40 +0200
Re: [PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() Joe Perches <joe@perches.com> - 2017-06-27 04:50 +0200
Re: [PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-27 05:50 +0200
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-06-27 00:40 +0200 |
| Subject | [PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() |
| Message-ID | <tWKPL-8jJ-5@gated-at.bofh.it> |
Value assigned to variable _ret_ at line 970 is overwritten either at
line 986 or 988, before it can be used. This makes such variable
assignment useless.
Addresses-Coverity-ID: 1226932
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
net/ipv4/netfilter/ip_tables.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2a55a40..648697c 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -967,7 +967,7 @@ static int get_info(struct net *net, void __user *user,
struct xt_table_info tmp;
if (compat) {
- ret = compat_table_info(private, &tmp);
+ compat_table_info(private, &tmp);
xt_compat_flush_offsets(AF_INET);
private = &tmp;
}
--
2.5.0
[toc] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-06-27 04:50 +0200 |
| Subject | Re: [PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() |
| Message-ID | <tWOJH-2xC-1@gated-at.bofh.it> |
| In reply to | #1675133 |
On Mon, 2017-06-26 at 17:34 -0500, Gustavo A. R. Silva wrote:
> Value assigned to variable _ret_ at line 970 is overwritten either at
> line 986 or 988, before it can be used. This makes such variable
> assignment useless.
>
> Addresses-Coverity-ID: 1226932
[]
> diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
[]
> @@ -967,7 +967,7 @@ static int get_info(struct net *net, void __user *user,
> struct xt_table_info tmp;
>
> if (compat) {
> - ret = compat_table_info(private, &tmp);
> + compat_table_info(private, &tmp);
why isn't it more appropriate to test the return value?
> xt_compat_flush_offsets(AF_INET);
> private = &tmp;
> }
[toc] | [prev] | [next] | [standalone]
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-06-27 05:50 +0200 |
| Subject | Re: [PATCH] netfilter: ip_tables: remove useless variable assignment in get_info() |
| Message-ID | <tWPFM-3aR-5@gated-at.bofh.it> |
| In reply to | #1675259 |
Hi Joe,
Quoting Joe Perches <joe@perches.com>:
> On Mon, 2017-06-26 at 17:34 -0500, Gustavo A. R. Silva wrote:
>> Value assigned to variable _ret_ at line 970 is overwritten either at
>> line 986 or 988, before it can be used. This makes such variable
>> assignment useless.
>>
>> Addresses-Coverity-ID: 1226932
> []
>> diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
> []
>> @@ -967,7 +967,7 @@ static int get_info(struct net *net, void __user *user,
>> struct xt_table_info tmp;
>>
>> if (compat) {
>> - ret = compat_table_info(private, &tmp);
>> + compat_table_info(private, &tmp);
>
> why isn't it more appropriate to test the return value?
>
Oh, in this particular case, based on git blame, the code has been
like that for more than 10 years. So my reasoning was that if it
hasn't been fixed yet, maybe that return value is not relevant.
But in case it turns out to actually be relevant, what do you think
about the following patch:
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -968,7 +968,8 @@ static int get_info(struct net *net, void __user *user,
if (compat) {
ret = compat_table_info(private, &tmp);
- xt_compat_flush_offsets(AF_INET);
+ if (!ret)
+ goto out;
private = &tmp;
}
#endif
@@ -986,14 +987,20 @@ static int get_info(struct net *net, void __user *user,
ret = -EFAULT;
else
ret = 0;
+ } else
+ ret = -ENOENT;
+out:
+ if (t) {
xt_table_unlock(t);
module_put(t->me);
- } else
- ret = -ENOENT;
+ }
+
#ifdef CONFIG_COMPAT
- if (compat)
+ if (compat) {
+ xt_compat_flush_offsets(AF_INET);
xt_compat_unlock(AF_INET);
+ }
#endif
return ret;
}
Thank you!
--
Gustavo A. R. Silva
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web