From: Lars-Peter Clausen Date: Fri, 29 Apr 2016 14:23:17 +0000 (+0200) Subject: deree-de5000: Provide dev_clear() X-Git-Tag: libsigrok-0.5.0~468 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=696b79d2aad00c359cb279cddcfab15c0f8ec08f;p=libsigrok.git deree-de5000: Provide dev_clear() 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 --- diff --git a/src/hardware/deree-de5000/api.c b/src/hardware/deree-de5000/api.c index b03c3a65..8619ccfb 100644 --- a/src/hardware/deree-de5000/api.c +++ b/src/hardware/deree-de5000/api.c @@ -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,