Commit
db81fbb58261 made sure to release a potentially previously
allocated list of enabled channels before (re-)building the list in the
current invocation of acquisition start.
This commit frees the memory in the error path near the failed creation
already, which reduces the period of time where unused resources are
held, and eliminates a memory leak when acquisition is not stopped after
failed start.
Both approaches can coexist. Freeing an empty list is perfectly fine.
struct sr_channel *ch;
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
struct sr_channel *ch;
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (hmo_check_channels(devc->enabled_channels) != SR_OK) {
sr_err("Invalid channel configuration specified!");
if (hmo_check_channels(devc->enabled_channels) != SR_OK) {
sr_err("Invalid channel configuration specified!");
+ ret = SR_ERR_NA;
+ goto free_enabled;
}
if (hmo_setup_channels(sdi) != SR_OK) {
sr_err("Failed to setup channel configuration!");
}
if (hmo_setup_channels(sdi) != SR_OK) {
sr_err("Failed to setup channel configuration!");
+ ret = SR_ERR;
+ goto free_enabled;
}
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
}
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
devc->current_channel = devc->enabled_channels;
return hmo_request_data(sdi);
devc->current_channel = devc->enabled_channels;
return hmo_request_data(sdi);
+
+free_enabled:
+ g_slist_free(devc->enabled_channels);
+ devc->enabled_channels = NULL;
+ return ret;
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi)