summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2016-02-09 08:53:28 +0100
committerJo-Philipp Wich <jow@openwrt.org>2016-02-09 08:53:31 +0100
commitb0d5399c3db83c2c8f9d8aae944f873343b3a038 (patch)
treee0757ea78fee9684e66baf3bb7f04af00dd8db2e /kmodloader.c
parent31d66f2c3b2afbc9eaae4e2c22103d0f79e9503e (diff)
downloadubox-b0d5399c3db83c2c8f9d8aae944f873343b3a038.tar.gz
kmodloader: fix open() error handling
Fixes kmodloader on systems without stdio and prevents fd leaks in case descriptor zero is opened. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kmodloader.c b/kmodloader.c
index 387678a..86e3f44 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -281,7 +281,7 @@ static struct module* get_module_info(const char *module, const char *name)
struct module *m;
struct stat s;
- if (!fd) {
+ if (fd < 0) {
ULOG_ERR("failed to open %s\n", module);
return NULL;
}
@@ -381,7 +381,7 @@ static int print_modinfo(char *module)
struct stat s;
char *map, *strings;
- if (!fd) {
+ if (fd < 0) {
ULOG_ERR("failed to open %s\n", module);
return -1;
}
@@ -466,7 +466,7 @@ static int insert_module(char *path, const char *options)
}
fd = open(path, O_RDONLY);
- if (!fd) {
+ if (fd < 0) {
ULOG_ERR("cannot open %s\n", path);
return ret;
}