Commit
4c7b720b9c63 fixed some error-handling paths but introduced another
memory leak; update and fix.
Fixes: 4c7b720b9c63 ("kmodloader: fix GCC fanalyzer warnings")
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
{
size_t buf_len = 0;
char *buf = NULL;
+ int rv = -1;
FILE *fp;
fp = fopen("/proc/modules", "r");
if (!fp) {
ULOG_ERR("failed to open /proc/modules\n");
- return -1;
+ goto out;
}
while (getline(&buf, &buf_len, fp) > 0) {
}
if (!n) {
ULOG_ERR("Failed to allocate memory for module\n");
- return -1;
+ goto out;
}
n->usage = m.usage;
n->state = LOADED;
}
+ rv = 0;
+out:
free(buf);
fclose(fp);
- return 0;
+ return rv;
}
static struct module* get_module_info(const char *module, const char *name)