summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-05-25 20:58:51 +0200
committerFelix Fietkau <nbd@openwrt.org>2014-05-25 20:58:51 +0200
commit0a80e92c03a90d5f6593b6af171bbed5480e0f55 (patch)
tree8de291649b064a18dda6618852a3beded0497a24
parentc80009a5f56550483c1f1f0b4fdae9c040abd0ae (diff)
downloadunitd-0a80e92c03a90d5f6593b6af171bbed5480e0f55.tar
unitd-0a80e92c03a90d5f6593b6af171bbed5480e0f55.zip
service: fix double-free in error path
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r--service/service.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/service/service.c b/service/service.c
index c566bc7..bfc8d49 100644
--- a/service/service.c
+++ b/service/service.c
@@ -216,13 +216,13 @@ service_handle_set(struct ubus_context *ctx, struct ubus_object *obj,
struct blob_attr *tb[__SERVICE_SET_MAX], *cur;
struct service *s = NULL;
const char *name;
- int ret = UBUS_STATUS_INVALID_ARGUMENT;
bool add = !strcmp(method, "add");
+ int ret;
blobmsg_parse(service_set_attrs, __SERVICE_SET_MAX, tb, blob_data(msg), blob_len(msg));
cur = tb[SERVICE_ATTR_NAME];
if (!cur)
- goto free;
+ return UBUS_STATUS_INVALID_ARGUMENT;
name = blobmsg_data(cur);
@@ -239,15 +239,11 @@ service_handle_set(struct ubus_context *ctx, struct ubus_object *obj,
ret = service_update(s, msg, tb, add);
if (ret)
- goto free;
+ return ret;
avl_insert(&services, &s->avl);
return 0;
-
-free:
- free(msg);
- return ret;
}
static void