Don't reset instance list in scan() callback

Some drivers set the device instance list to NULL in their scan() callback.
This means the driver loses all references to any devices contained in that
list and their resources will be leaked. Drivers can't free the devices at
this point either since an application might still use a device on the
list. So the existing devices on the instance list need to remain
unmodified during the scan() callback, even if that means that there will
be duplicates on the instance list. Only an explicit invocation of
sr_dev_clear() by the application is allowed to free the devices on the
instance list and reset the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-05-15 17:20:51 +02:00 committed by Uwe Hermann
parent d268866d29
commit 566007e15e
23 changed files with 0 additions and 24 deletions

View File

@ -83,7 +83,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
char *buf, **tokens;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;
conn = serialcomm = NULL;

View File

@ -81,7 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sr_info("Probing serial port %s.", conn);
drvc = di->context;
drvc->instances = NULL;
serial_flush(serial);
/* Let's get a bit of data and see if we can find a packet. */

View File

@ -74,7 +74,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {

View File

@ -94,7 +94,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {

View File

@ -82,7 +82,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
/* Probe for /dev/beaglelogic */
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))

View File

@ -44,7 +44,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
const char *conn;
drvc = di->context;
drvc->instances = NULL;
conn = BRYMEN_BC86X;
for (l = options; l; l = l->next) {

View File

@ -97,7 +97,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {

View File

@ -149,7 +149,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
char product[64], serial_num[64], connection_id[64];
drvc = di->context;
drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {

View File

@ -52,7 +52,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
const char *conn, *serialcomm;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;

View File

@ -50,7 +50,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {

View File

@ -209,7 +209,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
int i;
drvc = di->context;
drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {
src = l->data;

View File

@ -155,7 +155,6 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
serialcomm_given = FALSE;
@ -249,7 +248,6 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
sr_spew("scan_2x_bd232() called!");

View File

@ -67,7 +67,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);

View File

@ -112,7 +112,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
(void)options;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;
if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_CONN))) {

View File

@ -79,7 +79,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
conn = NULL;
serialcomm = NULL;
drvc = di->context;
drvc->instances = NULL;
for (l = options; l; l = l->next) {
src = l->data;

View File

@ -120,7 +120,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
(void)options;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;

View File

@ -86,7 +86,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
char reply[50], **tokens, *dummy;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;
conn = NULL;
serialcomm = NULL;

View File

@ -384,7 +384,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
devices = NULL;
drvc = drv->context;
drvc->instances = NULL;
sr_spew("scan() called!");

View File

@ -80,7 +80,6 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options)
devices = NULL;
drvc = drv->context;
drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {

View File

@ -74,7 +74,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sr_info("Probing serial port %s.", conn);
drvc = di->context;
drvc->instances = NULL;
serial_flush(serial);
/* Let's get a bit of data and see if we can find a packet. */

View File

@ -58,7 +58,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
drvc = di->context;
drvc->instances = NULL;
conn_devices = NULL;
for (l = options; l; l = l->next) {

View File

@ -50,7 +50,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
struct sr_serial_dev_inst *serial;
drvc = di->context;
drvc->instances = NULL;
devices = NULL;

View File

@ -48,7 +48,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
const char *conn;
drvc = di->context;
drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {