[LEDE-DEV] [PATCH] ubox: Fix some memory leaks
Rosen Penev
rosenp at gmail.com
Sat Dec 17 17:12:28 PST 2016
Avoids leaking memory when exiting early.
Signed-off by: Rosen <rosenp at gmail.com>
---
kmodloader.c | 8 ++++++--
log/logd.c | 2 +-
validate/validate.c | 4 +++-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/kmodloader.c b/kmodloader.c
index 40edbf0..f80835a 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -775,11 +775,15 @@ static int main_loader(int argc, char **argv)
strcpy(path, dir);
strcat(path, "*");
- if (scan_loaded_modules())
+ if (scan_loaded_modules()) {
+ free (path);
return -1;
+ }
- if (scan_module_folders())
+ if (scan_module_folders()) {
+ free (path);
return -1;
+ }
syslog(LOG_INFO, "kmodloader: loading kernel modules from %s\n", path);
diff --git a/log/logd.c b/log/logd.c
index d778909..915348e 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -84,7 +84,7 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
struct blob_attr *msg)
{
struct client *cl;
- struct blob_attr *tb[__READ_MAX];
+ struct blob_attr *tb[__READ_MAX] = { 0 };
struct log_head *l;
int count = 0;
int fds[2];
diff --git a/validate/validate.c b/validate/validate.c
index d5f9a55..e72b811 100644
--- a/validate/validate.c
+++ b/validate/validate.c
@@ -173,8 +173,10 @@ dt_type_list(struct dt_state *s, int nargs)
char *p, *str = strdup(s->value);
const char *value = s->value;
- if (!str || !nargs)
+ if (!str || !nargs) {
+ free(str);
return false;
+ }
for (p = strtok(str, " \t"); p; p = strtok(NULL, " \t"))
{
--
2.9.3
More information about the Lede-dev
mailing list