Skip to contentSkip to conversation

ipv4: fix NULL checking in devinet_ioctl()

PATCH In review Xi Wang 3 participants 3 messages Jan 5, 2013 – Jan 7, 2013

Subsystems (3)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 ipv4: fix NULL checking in devinet_ioctl()

The NULL pointer check `!ifa' should come before its first use.

---
 net/ipv4/devinet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/devinet.c +1 -1
index cc06a47..a8e4f26 100644
@@ -823,9 +823,9 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		if (!ifa) {
 			ret = -ENOBUFS;
 			ifa = inet_alloc_ifa();
-			INIT_HLIST_NODE(&ifa->hash);
 			if (!ifa)
 				break;
+			INIT_HLIST_NODE(&ifa->hash);
 			if (colon)
 				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
 			else
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Xi Wang

The NULL pointer check `!ifa' should come before its first use.

---
 net/ipv4/devinet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/devinet.c +0 -0
index cc06a47..a8e4f26 100644

net/ipv4/devinet.c int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) · line 831

Quoted 10 lines
net/ipv4/devinet.c +1 -1
@@ -823,9 +823,9 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		if (!ifa) {
 			ret = -ENOBUFS;
 			ifa = inet_alloc_ifa();
-			INIT_HLIST_NODE(&ifa->hash);
 			if (!ifa)
 				break;
+			INIT_HLIST_NODE(&ifa->hash);
 			if (colon)
 				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
 			else

Bug origin : commit fd23c3b31107e2fc483301ee923d8a1db14e53f4 (ipv4: Add hash table of interface addresses)

in linux-2.6.39

Thanks

maintainer
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Sat, 05 Jan 2013 15:10:02 -0800

Quoted 26 lines · Xi Wang
Quoted 12 lines

The NULL pointer check `!ifa' should come before its first use.

---
 net/ipv4/devinet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/devinet.c +0 -0
index cc06a47..a8e4f26 100644

net/ipv4/devinet.c int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) · line 831

Quoted 10 lines
net/ipv4/devinet.c +1 -1
@@ -823,9 +823,9 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		if (!ifa) {
 			ret = -ENOBUFS;
 			ifa = inet_alloc_ifa();
-			INIT_HLIST_NODE(&ifa->hash);
 			if (!ifa)
 				break;
+			INIT_HLIST_NODE(&ifa->hash);
 			if (colon)
 				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
 			else
Quoted 4 lines

Bug origin : commit fd23c3b31107e2fc483301ee923d8a1db14e53f4 (ipv4: Add hash table of interface addresses)

in linux-2.6.39

Applied and queued up for -stable, thanks.