Browse Source

interface-ip: fix possible null pointer dereference

Reported by Coverity in CID 1445749

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Hans Dedecker 4 years ago
parent
commit
42a38785f1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      interface-ip.c

+ 2 - 2
interface-ip.c

@@ -353,11 +353,11 @@ interface_ip_add_neighbor(struct interface *iface, struct blob_attr *attr, bool
 		ip = &iface->proto_ip;
 
 	neighbor = calloc(1,sizeof(*neighbor));
-	neighbor->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
-
 	if (!neighbor)
 		return;
 
+	neighbor->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
+
 	if ((cur = tb[NEIGHBOR_ADDRESS]) != NULL){
 		if (!inet_pton(af, blobmsg_data(cur), &neighbor->addr))
 			goto error;