linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [net/ipv6] Remove redundant null check in ah_mt6
@ 2020-06-25  2:36 Gaurav Singh
  2020-07-04  0:07 ` Pablo Neira Ayuso
  2020-07-27  1:52 ` [PATCH] netfilter: ip6tables: Remove redundant null checks Gaurav Singh
  0 siblings, 2 replies; 4+ messages in thread
From: Gaurav Singh @ 2020-06-25  2:36 UTC (permalink / raw)
  To: gaurav1086, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, open list:NETFILTER,
	open list:NETFILTER, open list:NETWORKING [IPv4/IPv6],
	open list

ah cannot be NULL since its already checked above after
assignment and is being dereferenced before in pr().
Remove the redundant null check.

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 net/ipv6/netfilter/ip6t_ah.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index 4e15a14435e4..70da2f2ce064 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -74,8 +74,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 		 ahinfo->hdrres, ah->reserved,
 		 !(ahinfo->hdrres && ah->reserved));
 
-	return (ah != NULL) &&
-		spi_match(ahinfo->spis[0], ahinfo->spis[1],
+	return spi_match(ahinfo->spis[0], ahinfo->spis[1],
 			  ntohl(ah->spi),
 			  !!(ahinfo->invflags & IP6T_AH_INV_SPI)) &&
 		(!ahinfo->hdrlen ||
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [net/ipv6] Remove redundant null check in ah_mt6
  2020-06-25  2:36 [PATCH] [net/ipv6] Remove redundant null check in ah_mt6 Gaurav Singh
@ 2020-07-04  0:07 ` Pablo Neira Ayuso
  2020-07-27  1:52 ` [PATCH] netfilter: ip6tables: Remove redundant null checks Gaurav Singh
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2020-07-04  0:07 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER,
	open list:NETWORKING [IPv4/IPv6],
	open list

Hi Gaurav,

On Wed, Jun 24, 2020 at 10:36:25PM -0400, Gaurav Singh wrote:
> ah cannot be NULL since its already checked above after
> assignment and is being dereferenced before in pr().
> Remove the redundant null check.

Could you collapse all your patches into one?

They look like the same logic change (patch description is the same in
the four patches in the series).

Please, prepend netfilter: to your patch subject, I suggest the
following subject for the collapsed patch.

        netfilter: ip6tables: Remove redundant null checks

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] netfilter: ip6tables: Remove redundant null checks
  2020-06-25  2:36 [PATCH] [net/ipv6] Remove redundant null check in ah_mt6 Gaurav Singh
  2020-07-04  0:07 ` Pablo Neira Ayuso
@ 2020-07-27  1:52 ` Gaurav Singh
  2020-07-29 20:44   ` Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Gaurav Singh @ 2020-07-27  1:52 UTC (permalink / raw)
  To: gaurav1086, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, open list:NETFILTER,
	open list:NETFILTER, open list:NETWORKING [IPv4/IPv6],
	open list

netfilter: ip6tables: Remove redundant null checks

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 net/ipv6/netfilter/ip6t_ah.c   | 3 +--
 net/ipv6/netfilter/ip6t_frag.c | 3 +--
 net/ipv6/netfilter/ip6t_hbh.c  | 3 +--
 net/ipv6/netfilter/ip6t_rt.c   | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index 4e15a14435e4..70da2f2ce064 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -74,8 +74,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 		 ahinfo->hdrres, ah->reserved,
 		 !(ahinfo->hdrres && ah->reserved));
 
-	return (ah != NULL) &&
-		spi_match(ahinfo->spis[0], ahinfo->spis[1],
+	return spi_match(ahinfo->spis[0], ahinfo->spis[1],
 			  ntohl(ah->spi),
 			  !!(ahinfo->invflags & IP6T_AH_INV_SPI)) &&
 		(!ahinfo->hdrlen ||
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index fb91eeee4a1e..3aad6439386b 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -85,8 +85,7 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 		 !((fraginfo->flags & IP6T_FRAG_NMF) &&
 		   (ntohs(fh->frag_off) & IP6_MF)));
 
-	return (fh != NULL) &&
-		id_match(fraginfo->ids[0], fraginfo->ids[1],
+	return id_match(fraginfo->ids[0], fraginfo->ids[1],
 			 ntohl(fh->identification),
 			 !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) &&
 		!((fraginfo->flags & IP6T_FRAG_RES) &&
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index 467b2a86031b..e7a3fb9355ee 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -86,8 +86,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 		  ((optinfo->hdrlen == hdrlen) ^
 		   !!(optinfo->invflags & IP6T_OPTS_INV_LEN))));
 
-	ret = (oh != NULL) &&
-	      (!(optinfo->flags & IP6T_OPTS_LEN) ||
+	ret = (!(optinfo->flags & IP6T_OPTS_LEN) ||
 	       ((optinfo->hdrlen == hdrlen) ^
 		!!(optinfo->invflags & IP6T_OPTS_INV_LEN)));
 
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index f633dc84ca3f..733c83d38b30 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -89,8 +89,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 		 !((rtinfo->flags & IP6T_RT_RES) &&
 		   (((const struct rt0_hdr *)rh)->reserved)));
 
-	ret = (rh != NULL) &&
-	      (segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
+	ret = (segsleft_match(rtinfo->segsleft[0], rtinfo->segsleft[1],
 			      rh->segments_left,
 			      !!(rtinfo->invflags & IP6T_RT_INV_SGS))) &&
 	      (!(rtinfo->flags & IP6T_RT_LEN) ||
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: ip6tables: Remove redundant null checks
  2020-07-27  1:52 ` [PATCH] netfilter: ip6tables: Remove redundant null checks Gaurav Singh
@ 2020-07-29 20:44   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2020-07-29 20:44 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER,
	open list:NETWORKING [IPv4/IPv6],
	open list

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-29 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25  2:36 [PATCH] [net/ipv6] Remove redundant null check in ah_mt6 Gaurav Singh
2020-07-04  0:07 ` Pablo Neira Ayuso
2020-07-27  1:52 ` [PATCH] netfilter: ip6tables: Remove redundant null checks Gaurav Singh
2020-07-29 20:44   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).