log: make valgrind less complain by freeing allocated memory
authorLuka Perkov <luka@openwrt.org>
Tue, 21 Apr 2015 17:04:45 +0000 (19:04 +0200)
committerJohn Crispin <blogic@openwrt.org>
Thu, 14 May 2015 04:25:44 +0000 (06:25 +0200)
Signed-off-by: Luka Perkov <luka@openwrt.org>
log/logd.c
log/syslog.c

index 4a7a746318018973fdf3183e574d46e639754f28..a4335ea9eb211191ed3485d7d1a87bb596defec7 100644 (file)
@@ -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;
index f75fed9e5139cd0b810d1bba49e15686609e7497..a596b487af4c46458424b5478917857da8fb686f 100644 (file)
@@ -299,4 +299,5 @@ log_shutdown(void)
        ustream_free(&klog.stream);
        close(slog.fd.fd);
        close(klog.fd.fd);
+       free(log);
 }