]> sigrok.org Git - libsigrok.git/commitdiff
sr: drivers using sr_usb_dev_inst_new() must free it properly as well
authorBert Vermeulen <redacted>
Sat, 4 Aug 2012 10:21:02 +0000 (12:21 +0200)
committerBert Vermeulen <redacted>
Sat, 4 Aug 2012 10:21:02 +0000 (12:21 +0200)
sr_usb_dev_inst_free() doesn't really do anything, but it might one
day.

hardware/fx2lafw/fx2lafw.c
hardware/genericdmm/api.c
hardware/zeroplus-logic-cube/zeroplus.c

index a6817340cc221f71ef20aba8cf89c5db6954c964..b05334a3515ab81b24ea7e6f122572e4be235411 100644 (file)
@@ -385,6 +385,7 @@ static int clear_instances(void)
                        continue;
                }
                hw_dev_close(sdi);
+               sr_usb_dev_inst_free(devc->usb);
                sdi = l->data;
                sr_dev_inst_free(sdi);
        }
index 5c868a4db137a68b42ee4d536972f8fc8ef3fd26..421360173ba3378ec3420f2a56d6109d2bffdab9 100644 (file)
@@ -422,6 +422,7 @@ static int hw_cleanup(void)
                        switch (devc->profile->transport) {
                        case DMM_TRANSPORT_USBHID:
                                /* TODO */
+                               sr_usb_dev_inst_free(devc->usb);
                                break;
                        case DMM_TRANSPORT_SERIAL:
                                if (devc->serial && devc->serial->fd != -1)
index 94ce37e18879cd54113c3b18d7142b03dcdf51bf..7dcda9cfd4dcc46310df96fcbad8a3ea9130eb3f 100644 (file)
@@ -232,10 +232,17 @@ static void clear_instances(void)
        GSList *l;
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
+       struct dev_context *devc;
 
        drvc = zdi->priv;
        for (l = drvc->instances; l; l = l->next) {
                sdi = l->data;
+               if (!(devc = sdi->priv)) {
+                       /* Log error, but continue cleaning up the rest. */
+                       sr_err("zeroplus: %s: sdi->priv was NULL, continuing", __func__);
+                       continue;
+               }
+               sr_usb_dev_inst_free(devc->usb);
                /* Properly close all devices... */
                hw_dev_close(sdi);
                /* ...and free all their memory. */