summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2022-07-18 15:12:38 -0700
committerHauke Mehrtens <hauke@hauke-m.de>2022-08-13 18:51:07 +0200
commit4c7b720b9c63b826fb9404e454ae54f2ef5649d5 (patch)
tree61b6e6415a0bf3dd0008a413b7c7a1a9c1e916d9 /kmodloader.c
parentfa6cb9a3810f5e609e2f11cd8e0a474f58a990c5 (diff)
downloadubox-4c7b720b9c63b826fb9404e454ae54f2ef5649d5.tar.gz
kmodloader: fix GCC fanalyzer warnings
memory leaks and missing NULL checks. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/kmodloader.c b/kmodloader.c
index 4b2ffa7..b2e7a8b 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -336,6 +336,11 @@ static int scan_loaded_modules(void)
/* 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;
}
@@ -583,6 +588,11 @@ static int insert_module(char *path, const char *options)
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;
@@ -1164,6 +1174,8 @@ load_options(void)
continue;
}
}
+
+ fclose(f);
}
int main(int argc, char **argv)