Blob Blame History Raw
From b57c64f1aa5c51dd785f2572636b8c41ada06d72 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 30 Aug 2011 15:10:46 +0200
Subject: [PATCH] network: NULL dereference fix

Variable ifindex dereferenced on line 242 before null check on line 249.
---
 network/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/network/common.c b/network/common.c
index 4704072..a223685 100644
--- a/network/common.c
+++ b/network/common.c
@@ -240,13 +240,15 @@ int bnep_if_down(const char *devname)
 
 int bnep_add_to_bridge(const char *devname, const char *bridge)
 {
-	int ifindex = if_nametoindex(devname);
+	int ifindex;
 	struct ifreq ifr;
 	int sk, err;
 
 	if (!devname || !bridge)
 		return -EINVAL;
 
+	ifindex = if_nametoindex(devname);
+
 	sk = socket(AF_INET, SOCK_STREAM, 0);
 	if (sk < 0)
 		return -1;
-- 
1.8.0.1