exit(execve(exec_argv[0], exec_argv, pc->envp));
} else if (pc->process.pid < 0) {
/* fork error */
+ free(script);
hotplug_free(pc);
return;
}
size_t envz = 0;
struct hotplug_process *pc;
bool async = true;
+ int err = UBUS_STATUS_UNKNOWN_ERROR;
blobmsg_parse(hotplug_policy, __HOTPLUG_MAX, tb, blobmsg_data(msg), blobmsg_len(msg));
}
envle->avl.key = envle->env;
if (avl_insert(&env, &envle->avl) == -1) {
+ free(envle->env);
free(envle);
goto err_envle;
}
}
}
+ /* synchronous calls are unsupported for now */
+ if (!async) {
+ err = UBUS_STATUS_NOT_SUPPORTED;
+ goto err_envle;
+ }
+
/* allocating new environment */
avl_for_each_element(&env, envle, avl)
++envz;
free(envle);
}
- /* glob'ing for hotplug scripts */
- if (asprintf(&globstr, "%s/%s/*", HOTPLUG_BASEDIR, subsys) == -1) {
- env_free(envp);
- return UBUS_STATUS_UNKNOWN_ERROR;
- }
-
- /* synchronous calls are unsupported for now */
- if (!async) {
- env_free(envp);
- return UBUS_STATUS_NOT_SUPPORTED;
- }
-
pc = calloc(1, sizeof(struct hotplug_process));
if (!pc) {
env_free(envp);
pc->cnt = 0;
pc->ubus = obj;
+ /* glob'ing for hotplug scripts */
+ if (asprintf(&globstr, "%s/%s/*", HOTPLUG_BASEDIR, subsys) == -1) {
+ env_free(envp);
+ return UBUS_STATUS_UNKNOWN_ERROR;
+ }
+
if (glob(globstr, GLOB_DOOFFS, NULL, &pc->globbuf)) {
free(globstr);
hotplug_free(pc);
free(envle);
}
- return UBUS_STATUS_UNKNOWN_ERROR;
+ return err;
}
static const struct ubus_method hotplug_methods[] = {