X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto-shell.c;h=41031c3553983000d4a406a5c31806eab7975190;hp=5937e522818cee0c7b2385920ce8fc72023b5598;hb=273eb40f725de67011c092d2ed9f07a2d7f84ac3;hpb=d43eb8e1fd680fc14c398150665cf3a954fe5510 diff --git a/proto-shell.c b/proto-shell.c index 5937e52..41031c3 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -138,9 +138,11 @@ proto_shell_teardown_cb(struct uloop_process *p, int ret) struct proto_shell_state *state; state = container_of(p, struct proto_shell_state, teardown_task); - state->proto.proto_event(&state->proto, IFPEV_DOWN); + if (state->l3_dev.dev) device_remove_user(&state->l3_dev); + + state->proto.proto_event(&state->proto, IFPEV_DOWN); } static void @@ -382,11 +384,11 @@ proto_shell_parse_config(struct config_param_list *config, json_object *obj) int str_len = 0; int i; - attrs = calloc(1, sizeof(*attrs)); + config->n_params = json_object_array_length(obj); + attrs = calloc(1, sizeof(*attrs) * config->n_params); if (!attrs) return NULL; - config->n_params = json_object_array_length(obj); config->params = attrs; for (i = 0; i < config->n_params; i++) { json_object *cur, *name, *type; @@ -408,7 +410,7 @@ proto_shell_parse_config(struct config_param_list *config, json_object *obj) if (attrs[i].type > BLOBMSG_TYPE_LAST) goto error; - str_len += strlen(attrs[i].name + 1); + str_len += strlen(attrs[i].name) + 1; } str_buf = malloc(str_len);