sr: don't free driver-specific per-device struct in drivers

sr_dev_inst_free() takes care of that.
This commit is contained in:
Bert Vermeulen 2012-02-14 12:26:22 +01:00
parent da1466d677
commit 341ce41545
6 changed files with 11 additions and 29 deletions

View File

@ -159,7 +159,6 @@ static int hw_cleanup(void)
return SR_ERR_BUG;
}
g_free(sdi->priv);
sr_dev_inst_free(sdi);
return SR_OK;

View File

@ -735,7 +735,6 @@ static int hw_cleanup(void)
ret = SR_ERR_BUG;
continue;
}
g_free(sdi->priv);
sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);

View File

@ -695,17 +695,6 @@ static int hw_cleanup(void)
ret = SR_ERR_BUG;
continue;
}
#if 0
/*
* Fixes a segfault as it's free()d elsewhere already.
* TODO: Document who is supposed to free this, and when.
*/
if (sdi->priv != NULL)
g_free(sdi->priv);
else
sr_err("la8: %s: sdi->priv was NULL, nothing "
"to do", __func__);
#endif
sr_dev_inst_free(sdi); /* Returns void. */
}
g_slist_free(device_instances); /* Returns void. */

View File

@ -522,8 +522,9 @@ static int hw_cleanup(void)
{
GSList *l;
struct sr_device_instance *sdi;
int ret = SR_OK;
int ret;
ret = SR_OK;
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
if (!(sdi = l->data)) {
@ -534,14 +535,12 @@ static int hw_cleanup(void)
}
if (sdi->serial->fd != -1)
serial_close(sdi->serial->fd);
g_free(sdi->priv);
sdi->priv = NULL;
sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
return SR_OK;
return ret;
}
static int hw_opendev(int device_index)

View File

@ -488,16 +488,15 @@ static int hw_closedev(int device_index)
static int hw_cleanup(void)
{
GSList *l;
struct sr_device_instance *sdi;
/* TODO: Error handling. */
/* Properly close all devices... */
for (l = device_instances; l; l = l->next)
close_device((struct sr_device_instance *)l->data);
/* ...and free all their memory. */
for (l = device_instances; l; l = l->next)
g_free(l->data);
for (l = device_instances; l; l = l->next) {
sdi = l->data;
/* Properly close all devices... */
close_device(sdi);
/* ...and free all their memory. */
sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;

View File

@ -162,11 +162,8 @@ static int hw_cleanup(void)
{
GSList *l;
/* TODO: Error handling. */
for (l = device_instances; l; l = l->next)
sr_dev_inst_free(l->data);
g_slist_free(device_instances);
device_instances = NULL;