net: netfilter/xt_CT.c: fix uninitialized variable
Subsystems (3)
PATCH 1/1 net: netfilter/xt_CT.c: fix uninitialized variable
If CONFIG_NF_CONNTRACK_ZONES is not defined, the variable ret might be uninitialized when it goes to err1 through line 125 and 263 respectively. So I change these goto err1 to return -EINVAL directly.
--- net/netfilter/xt_CT.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/xt_CT.c +2 -2
@@ -122,7 +122,7 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif ret =nf_ct_l3proto_try_module_get (par->family);
@@ -260,7 +260,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif ret =nf_ct_l3proto_try_module_get (par->family);
Signature · 1 line
1.7.10.4
Quoted 23 lines · Cong Ding
If
CONFIG_NF_CONNTRACK_ZONESis not defined, the variable ret might be uninitialized when it goes to err1 through line 125 and 263 respectively. So I change these goto err1 to return-EINVALdirectly.Signed-off-by Cong Ding <[email protected]>--- net/netfilter/xt_CT.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/netfilter/xt_CT.c +1
-1@@ -122,7 +122,7 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif ret =nf_ct_l3proto_try_module_get (par->family);
net/netfilter/xt_CT.c static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par) · line 264
Quoted 6 lines
net/netfilter/xt_CT.c +1
-1@@ -260,7 +260,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif
In dropping both goto's, you left the err1 label unused. Wouldn't just initializing ret to -EINVAL be easier and cleaner? Then you wouldn't be messing with the flow of the function.
-PJ
Quoted 25 lines · Peter P
Quoted 24 lines · Cong Ding
If
CONFIG_NF_CONNTRACK_ZONESis not defined, the variable ret might be uninitialized when it goes to err1 through line 125 and 263 respectively. So I change these goto err1 to return-EINVALdirectly.Signed-off-by Cong Ding <[email protected]>--- net/netfilter/xt_CT.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/netfilter/xt_CT.c +1
-1@@ -122,7 +122,7 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif ret =nf_ct_l3proto_try_module_get (par->family);@@ -260,7 +260,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)
Quoted 9 lines
net/netfilter/xt_CT.c static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par) · line 126
Quoted 5 lines
net/netfilter/xt_CT.c +1
-1#ifndef CONFIG_NF_CONNTRACK_ZONES if (info->zone) - goto err1; +return -EINVAL ;#endif In dropping both goto's, you left the err1 label unused. Wouldn't just initializing ret to
-EINVALbe easier and cleaner? Then you wouldn't be messing with the flow of the function.
The label err1 are also used in line 130 and 298. I change it to "return -EINVAL" rather than initialize ret to -EINVAL is to keep it the same as line 115 and 253. Otherwise, we should change line 115 and 253 to be goto err1, too?
- cong
Pablo Neira Ayuso
maintainerHi Cong,
Quoted 3 lines · Cong Ding
If
CONFIG_NF_CONNTRACK_ZONESis not defined, the variable ret might be uninitialized when it goes to err1 through line 125 and 263 respectively. So I change these goto err1 to return-EINVALdirectly.
This is already fixed in the net tree.