]> sigrok.org Git - libsigrok.git/commitdiff
beaglelogic: Fix PulseView crash on close
authorKumar Abhishek <redacted>
Sat, 23 Sep 2017 05:51:15 +0000 (11:21 +0530)
committerUwe Hermann <redacted>
Tue, 26 Sep 2017 16:14:46 +0000 (18:14 +0200)
Use dev_clear instead of std_dev_clear to clean up our private
data structure.

Signed-off-by: Kumar Abhishek <redacted>
src/hardware/beaglelogic/api.c
src/hardware/beaglelogic/beaglelogic_tcp.c

index b933965dab0470882dae4224088ea45ccbca8450..3188d8f3dc2d462684864b28df2ada7cbd5eb4a6 100644 (file)
@@ -150,6 +150,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 err_free:
        g_free(sdi->model);
        g_free(sdi->version);
+       g_free(devc->address);
+       g_free(devc->port);
        g_free(devc);
        g_free(sdi);
 
@@ -207,10 +209,24 @@ static int dev_close(struct sr_dev_inst *sdi)
                devc->beaglelogic->munmap(devc);
        devc->beaglelogic->close(devc);
 
+       return SR_OK;
+}
+
+static void clear_helper(struct dev_context *devc)
+{
        if (devc->tcp_buffer)
                g_free(devc->tcp_buffer);
 
-       return SR_OK;
+       if (devc->address)
+               g_free(devc->address);
+
+       if (devc->port)
+               g_free(devc->port);
+}
+
+static int dev_clear(const struct sr_dev_driver *di)
+{
+       return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
 }
 
 static int config_get(uint32_t key, GVariant **data,
@@ -379,7 +395,7 @@ static struct sr_dev_driver beaglelogic_driver_info = {
        .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = std_dev_list,
-       .dev_clear = std_dev_clear,
+       .dev_clear = dev_clear,
        .config_get = config_get,
        .config_set = config_set,
        .config_list = config_list,
index 2c303c976c1bef216e2f31cac7642a91eb3fe4f6..b3fcb0ab166c2d8e526c6f17773410c06b72d2ce 100644 (file)
@@ -242,9 +242,6 @@ static int beaglelogic_open(struct dev_context *devc) {
 }
 
 static int beaglelogic_close(struct dev_context *devc) {
-       g_free(devc->address);
-       g_free(devc->port);
-
        if (close(devc->socket) < 0)
                return SR_ERR;