[OpenWrt-Devel] [PATCH 3/4] [ubox] log: make valgrind less complain by freeing allocated memory
Luka Perkov
luka at openwrt.org
Tue Apr 21 13:04:45 EDT 2015
Signed-off-by: Luka Perkov <luka at openwrt.org>
---
log/logd.c | 5 ++++-
log/syslog.c | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/log/logd.c b/log/logd.c
index 4a7a746..a4335ea 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -70,6 +70,7 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
struct log_head *l;
int count = 0;
int fds[2];
+ int ret;
if (msg) {
blobmsg_parse(&read_policy, 1, &tb, blob_data(msg), blob_len(msg));
@@ -96,7 +97,9 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
blobmsg_add_u32(&b, "source", l->source);
blobmsg_add_u64(&b, "time", l->ts.tv_sec * 1000LL);
l = log_list(count, l);
- if (ustream_write(&cl->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false) <= 0)
+ ret = ustream_write(&cl->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false);
+ blob_buf_free(&b);
+ if (ret < 0)
break;
}
return 0;
diff --git a/log/syslog.c b/log/syslog.c
index f75fed9..a596b48 100644
--- a/log/syslog.c
+++ b/log/syslog.c
@@ -299,4 +299,5 @@ log_shutdown(void)
ustream_free(&klog.stream);
close(slog.fd.fd);
close(klog.fd.fd);
+ free(log);
}
--
2.3.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list