summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Marangi2024-01-21 23:39:50 +0000
committerChristian Marangi2024-01-21 23:51:56 +0000
commitb2f6da671f7c747fe9e65080c7c012b945cacb50 (patch)
treede57a7a5557d9917c89df8572fad69cdd4c03e21
parentc006dccecb6f1cf694c9fb9efc6727cbd2ab9ae4 (diff)
kmodloader: Fix NULL pointer dereferences error
Fix NULL pointer dereferences reported by Coverity Scan. Return early instead of jumping to out and trying to fclose a NULL pointer. Fix - CID 1586642: Null pointer dereferences (FORWARD_NULL) - CID 1586641: Null pointer dereferences (FORWARD_NULL) Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
-rw-r--r--kmodloader.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kmodloader.c b/kmodloader.c
index b4ef52a..2cb6088 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -328,7 +328,7 @@ static int scan_loaded_modules(void)
fp = fopen("/proc/modules", "r");
if (!fp) {
ULOG_ERR("failed to open /proc/modules\n");
- goto out;
+ return -1;
}
while (getline(&buf, &buf_len, fp) > 0) {
@@ -499,7 +499,7 @@ static int scan_builtin_modules(void)
int rv = -1;
if (!module_folders && init_module_folders())
- goto err;
+ return -1;
for (p = module_folders; *p; p++) {
snprintf(path, sizeof(path), "%s%s", *p, MOD_BUILTIN);
if (!stat(path, &st) && S_ISREG(st.st_mode)) {
@@ -509,7 +509,7 @@ static int scan_builtin_modules(void)
}
}
if (!fp)
- goto out; /* OK if modules.builtin unavailable */
+ return 0; /* OK if modules.builtin unavailable */
while (getline(&buf, &buf_len, fp) > 0) {
struct module *m;
@@ -529,7 +529,7 @@ static int scan_builtin_modules(void)
goto err;
}
}
-out:
+
rv = 0;
err:
free(buf);