]> sigrok.org Git - libsigrok.git/commitdiff
deree-de5000: Provide dev_clear()
authorLars-Peter Clausen <redacted>
Fri, 29 Apr 2016 14:23:17 +0000 (16:23 +0200)
committerLars-Peter Clausen <redacted>
Tue, 3 May 2016 19:24:12 +0000 (21:24 +0200)
Devices for the deree-de5000 driver do have additional data attached to it
that needs to be freed when the device is freed. While the driver gets it
right for the cleanup() callback it does not implement a dev_clear()
callback, so the default dev_clear() implementation is used which will not
free the additional data. This will cause memory leaks when sr_dev_clear()
is called for this driver.

To fix this provide a dev_clear() implementation that frees the additional
data.

Signed-off-by: Lars-Peter Clausen <redacted>
src/hardware/deree-de5000/api.c

index b03c3a65f5e1b27fa90b5b4408287821c15b38dd..8619ccfbd3f66537aff0ef2597cdc590a01c1784 100644 (file)
@@ -49,11 +49,16 @@ static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static int cleanup(const struct sr_dev_driver *di)
+static int dev_clear(const struct sr_dev_driver *di)
 {
        return std_dev_clear(di, es51919_serial_clean);
 }
 
+static int cleanup(const struct sr_dev_driver *di)
+{
+       return dev_clear(di);
+}
+
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
@@ -74,7 +79,7 @@ SR_PRIV struct sr_dev_driver deree_de5000_driver_info = {
        .cleanup = cleanup,
        .scan = scan,
        .dev_list = dev_list,
-       .dev_clear = NULL,
+       .dev_clear = dev_clear,
        .config_get = es51919_serial_config_get,
        .config_set = es51919_serial_config_set,
        .config_list = es51919_serial_config_list,