Patchwork [10/11] nf/dccp: merge errorpaths

login
register
mail settings
Submitter Ilpo Järvinen
Date Dec. 13, 2008, 7:17 p.m.
Message ID <12291958721873-git-send-email-ilpo.jarvinen@helsinki.fi>
Download mbox | patch
Permalink /patch/13839/
State Superseded
Delegated to: David Miller
Headers show

Comments

Ilpo Järvinen - Dec. 13, 2008, 7:17 p.m.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Cc: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/xt_dccp.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

Patch

diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index e5d3e86..0989f29 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -45,10 +45,8 @@  dccp_find_option(u_int8_t option,
 	unsigned int optlen = dh->dccph_doff*4 - __dccp_hdr_len(dh);
 	unsigned int i;
 
-	if (dh->dccph_doff * 4 < __dccp_hdr_len(dh)) {
-		*hotdrop = true;
-		return false;
-	}
+	if (dh->dccph_doff * 4 < __dccp_hdr_len(dh))
+		goto invalid;
 
 	if (!optlen)
 		return false;
@@ -57,9 +55,7 @@  dccp_find_option(u_int8_t option,
 	op = skb_header_pointer(skb, protoff + optoff, optlen, dccp_optbuf);
 	if (op == NULL) {
 		/* If we don't have the whole header, drop packet. */
-		spin_unlock_bh(&dccp_buflock);
-		*hotdrop = true;
-		return false;
+		goto partial;
 	}
 
 	for (i = 0; i < optlen; ) {
@@ -76,6 +72,12 @@  dccp_find_option(u_int8_t option,
 
 	spin_unlock_bh(&dccp_buflock);
 	return false;
+
+partial:
+	spin_unlock_bh(&dccp_buflock);
+invalid:
+	*hotdrop = true;
+	return false;
 }