Commit 85de9def authored by Hans Dedecker's avatar Hans Dedecker

interface: fix memory leak on error in __interface_add()

Detected by Coverity in cid 1441495
Signed-off-by: default avatarHans Dedecker <dedeckeh@gmail.com>
parent 4b83102d
......@@ -892,7 +892,7 @@ static bool __interface_add(struct interface *iface, struct blob_attr *config, b
{
struct blob_attr *tb[IFACE_ATTR_MAX];
struct blob_attr *cur;
char *name = iface->dynamic ? strdup(iface->name) : NULL;
char *name = NULL;
blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
blob_data(config), blob_len(config));
......@@ -908,6 +908,13 @@ static bool __interface_add(struct interface *iface, struct blob_attr *config, b
iface->ifname = blobmsg_data(cur);
}
if (iface->dynamic) {
name = strdup(iface->name);
if (!name)
return false;
}
iface->config = config;
vlist_add(&interfaces, &iface->node, iface->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment