interface-ip: fix possible null pointer dereference
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 13 Jun 2019 19:59:31 +0000 (21:59 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 13 Jun 2019 20:01:26 +0000 (22:01 +0200)
Reported by Coverity in CID 1445749

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface-ip.c

index 864de5059e5906a88a10012f98acbf00c9390937..c159e09133165aec461d34c8a42311d7f5e69bd3 100644 (file)
@@ -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;