X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=kmodloader.c;h=0afc79560693e9a67bf0ca74a0dfd934b5387e75;hb=811ca6c2234a3d13efef55947a9cff8bef56ceb7;hp=259ac52d8fa9ce1a4aab43e704525d8583a756c0;hpb=11cb29e15d68e05a1fef8376fee6d7549ced840a;p=project%2Fubox.git diff --git a/kmodloader.c b/kmodloader.c index 259ac52..0afc795 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -311,12 +311,13 @@ static int scan_loaded_modules(void) { 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) { @@ -338,16 +339,18 @@ static int scan_loaded_modules(void) } 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)