aboutsummaryrefslogtreecommitdiff
path: root/toys/other/insmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other/insmod.c')
-rw-r--r--toys/other/insmod.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/toys/other/insmod.c b/toys/other/insmod.c
index 8aa959a9..81721a31 100644
--- a/toys/other/insmod.c
+++ b/toys/other/insmod.c
@@ -22,7 +22,7 @@ void insmod_main(void)
{
char * buf = NULL;
int len, res, i;
- int fd = xopen(toys.optargs[0], O_RDONLY);
+ int fd = xopen(*toys.optargs, O_RDONLY);
len = fdlength(fd);
buf = xmalloc(len);
@@ -30,13 +30,17 @@ void insmod_main(void)
i = 1;
while(toys.optargs[i] &&
- strlen(toybuf) + strlen(toys.optargs[i]) + 2 < sizeof(toybuf)) {
+ strlen(toybuf) + strlen(toys.optargs[i]) + 2 < sizeof(toybuf))
+ {
strcat(toybuf, toys.optargs[i++]);
strcat(toybuf, " ");
}
res = init_module(buf, len, toybuf);
- if (CFG_TOYBOX_FREE && buf != toybuf) free(buf);
+ if (CFG_TOYBOX_FREE) {
+ if (buf != toybuf) free(buf);
+ close(fd);
+ }
if (res) perror_exit("failed to load %s", toys.optargs[0]);
}