kmodloader has a restriction of storing only 32 aliases for a given
module; as modules can have easily more than 32 aliases let's remove
the restriction by using a dynamic allocation mechanism when retrieving
the aliases.

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

diff --git a/kmodloader.c b/kmodloader.c
index a4d492d..2ece0c2 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -340,7 +340,7 @@ static struct module* get_module_info(const char *module, 
const char *name)
        int fd = open(module, O_RDONLY);
        unsigned int offset, size;
        char *map = MAP_FAILED, *strings, *dep = NULL;
-       const char *aliases[32] = { 0 };
+       const char **aliases = NULL;
        int naliases = 0;
        struct module *m = NULL;
        struct stat s;
@@ -383,11 +383,11 @@ static struct module* get_module_info(const char *module, 
const char *name)
                if (!strncmp(strings, "depends=", len + 1))
                        dep = sep;
                else if (!strncmp(strings, "alias=", len + 1)) {
-                       if (naliases < ARRAY_SIZE(aliases))
-                               aliases[naliases++] = sep;
-                       else
-                               ULOG_WARN("module %s has more than %d aliases: 
truncated",
-                                               name, ARRAY_SIZE(aliases));
+                       aliases = realloc(aliases, sizeof(sep) * (naliases + 
1));
+                       if (!aliases)
+                               goto out;
+
+                       aliases[naliases++] = sep;
                }
                strings = &sep[strlen(sep)];
        }
@@ -404,6 +404,8 @@ out:
        if (fd >= 0)
                close(fd);
 
+       free(aliases);
+
        return m;
 }
 
-- 
1.9.1


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

Reply via email to