Signed-off-by: Hans Dedecker <dedec...@gmail.com>
---
 kmodloader.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/kmodloader.c b/kmodloader.c
index 2ece0c2..1ddde0d 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -565,6 +565,9 @@ static int insert_module(char *path, const char *options)
        }
 
        data = malloc(s.st_size);
+       if (!data)
+               goto out;
+
        if (read(fd, data, s.st_size) == s.st_size) {
                ret = syscall(__NR_init_module, data, (unsigned long) 
s.st_size, options);
                if (errno == EEXIST)
@@ -573,6 +576,7 @@ static int insert_module(char *path, const char *options)
        else
                ULOG_ERR("failed to read full module %s\n", path);
 
+out:
        close(fd);
        free(data);
 
@@ -694,6 +698,11 @@ static int main_insmod(int argc, char **argv)
                len += strlen(argv[i]) + 1;
 
        options = malloc(len);
+       if (!options) {
+               ret = -1;
+               goto err;
+       }
+
        options[0] = 0;
        cur = options;
        for (i = 2; i < argc; i++) {
@@ -899,6 +908,9 @@ static int main_loader(int argc, char **argv)
                dir = argv[1];
 
        path = malloc(strlen(dir) + 2);
+       if (!path)
+               return -1;
+
        strcpy(path, dir);
        strcat(path, "*");
 
-- 
1.9.1


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to