interface: Fix possbile segfault
[project/netifd.git] / interface.c
index 2aab37cc9ecdf97949c94a9a62d44633fa3e4785..7b18cef58a47d8aed15c0e568652a54b1d8d2ae7 100644 (file)
@@ -189,6 +189,9 @@ interface_add_data(struct interface *iface, const struct blob_attr *data)
        }
 
        n = calloc(1, sizeof(*n) + len);
+       if (!n)
+               return UBUS_STATUS_UNKNOWN_ERROR;
+
        memcpy(n->data, data, len);
        n->node.key = blobmsg_name(n->data);
        avl_insert(&iface->data, &n->node);