/* possibly a module outside /lib/modules/<ver>/ */
n = alloc_module(m.name, NULL, 0, m.depends, m.size);
}
+ if (!n) {
+ ULOG_ERR("Failed to allocate memory for module\n");
+ return -1;
+ }
+
n->usage = m.usage;
n->state = LOADED;
}
unsigned int offset, size;
char *map = MAP_FAILED, *strings, *dep = NULL;
const char **aliases = NULL;
+ const char **aliasesr;
int naliases = 0;
struct module *m = NULL;
struct stat s;
if (!strncmp(strings, "depends=", len + 1))
dep = sep;
else if (!strncmp(strings, "alias=", len + 1)) {
- aliases = realloc(aliases, sizeof(sep) * (naliases + 1));
- if (!aliases) {
+ aliasesr = realloc(aliases, sizeof(sep) * (naliases + 1));
+ if (!aliasesr) {
ULOG_ERR("out of memory\n");
goto out;
}
+ aliases = aliasesr;
aliases[naliases++] = sep;
}
strings = &sep[strlen(sep)];
struct stat s;
int fd, ret = -1;
+ if (!path) {
+ ULOG_ERR("Path not specified\n");
+ return ret;
+ }
+
if (stat(path, &s)) {
ULOG_ERR("missing module %s\n", path);
return ret;
struct module *m;
glob_t gl;
char *path;
- int fail, j;
+ int ret = 0, fail, j;
if (argc > 1)
dir = argv[1];
strcat(path, "*");
if (scan_module_folders()) {
- free (path);
- return -1;
+ ret = -1;
+ goto free_path;
}
if (scan_loaded_modules()) {
- free (path);
- return -1;
+ ret = -1;
+ goto free_path;
}
ULOG_INFO("loading kernel modules from %s\n", path);
if (m->opts) {
char *prev = m->opts;
- asprintf(&m->opts, "%s %s", prev, opts);
+ fail = asprintf(&m->opts, "%s %s", prev, opts);
free(prev);
+ if (fail < 0) {
+ ULOG_ERR("out of memory for opts %s\n", opts);
+ free(mod);
+ fclose(fp);
+ ret = -1;
+ goto out;
+ }
} else {
m->opts = strdup(opts);
}
out:
globfree(&gl);
+free_path:
free(path);
- return 0;
+ return ret;
}
static inline char weight(char c)
continue;
}
}
+
+ fclose(f);
}
int main(int argc, char **argv)