Skip to contentSkip to conversation

x25_forward_call(): fix NULL dereferences

PATCH In review Adrian Bunk 2 participants 2 messages Mar 19, 2007 – Mar 20, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x25_forward_call(): fix NULL dereferences

This patch fixes two NULL dereferences spotted by the Coverity checker.

For a better understanding, the "diff -uwp" output (that ignores the indentation changes) is:

net/x25/x25_forward.c renamed from net/x25/x25_forward.c.old +4 -2
@@ -25,9 +25,10 @@ int x25_forward_call(struct x25_address 
 	struct sk_buff *skbn;
 	short same_lci = 0;
 	int rc = 0;
 
-	if ((rt = x25_get_route(dest_addr)) != NULL) {
+	if ((rt = x25_get_route(dest_addr)) == NULL)
+		goto out_no_route;
 
 		if ((neigh_new = x25_get_neigh(rt->dev)) == NULL) {
 			/* This shouldnt happen, if it occurs somehow
 			 * do something sensible
@@ -75,16 +76,17 @@ int x25_forward_call(struct x25_address 
 			goto out_put_nb;
 		}
 		x25_transmit_link(skbn, neigh_new);
 		rc = 1;
-	}
 
 
 out_put_nb:
 	x25_neigh_put(neigh_new);
 
 out_put_route:
 	x25_route_put(rt);
+
+out_no_route:
 	return rc;
 }
 
 

---

 net/x25/x25_forward.c |   86 +++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 42 deletions(-)
net/x25/x25_forward.c renamed from net/x25/x25_forward.c.old +44 -42

108 lines not on this page · raw message

maintainer
#1 lore raw

From: Adrian Bunk <[email protected]>
Date: Mon, 19 Mar 2007 10:24:03 +0100

Quoted 4 lines

This patch fixes two NULL dereferences spotted by the Coverity checker.

For a better understanding, the "diff -uwp" output (that ignores the indentation changes) is:

I'll apply this, thanks Adrian.