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 <redacted>
char *buf, **tokens;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
conn = serialcomm = NULL;
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. */
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
/* Probe for /dev/beaglelogic */
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
const char *conn;
drvc = di->context;
- drvc->instances = NULL;
conn = BRYMEN_BC86X;
for (l = options; l; l = l->next) {
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
char product[64], serial_num[64], connection_id[64];
drvc = di->context;
- drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {
const char *conn, *serialcomm;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
int i;
drvc = di->context;
- drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {
src = l->data;
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
serialcomm_given = FALSE;
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
sr_spew("scan_2x_bd232() called!");
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);
(void)options;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_CONN))) {
conn = NULL;
serialcomm = NULL;
drvc = di->context;
- drvc->instances = NULL;
for (l = options; l; l = l->next) {
src = l->data;
(void)options;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
char reply[50], **tokens, *dummy;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
conn = NULL;
serialcomm = NULL;
devices = NULL;
drvc = drv->context;
- drvc->instances = NULL;
sr_spew("scan() called!");
devices = NULL;
drvc = drv->context;
- drvc->instances = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
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. */
devices = NULL;
drvc = di->context;
- drvc->instances = NULL;
conn_devices = NULL;
for (l = options; l; l = l->next) {
struct sr_serial_dev_inst *serial;
drvc = di->context;
- drvc->instances = NULL;
devices = NULL;
const char *conn;
drvc = di->context;
- drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {