More malloc/free cleanup in cable drivers (Hartley Sweeten)

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1263 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Kolja Waschk 17 years ago
parent 809980e5e2
commit 888ec27ec3

@ -1,3 +1,11 @@
2008-05-29 Kolja Waschk <kawk>
* src/tap/cable/wiggler.c src/tap/cable/generic_usbconn.c,
src/tap/cable/usbblaster.c, src/tap/cable/vision_ep9307.c,
src/tap/cable/jim.c, src/tap/cable/ft2232.c,
src/tap/cable/generic_parport.c: More malloc/free cleanup
in cable drivers (Hartley Sweeten)
2008-05-28 Kolja Waschk <kawk>
* src/cmd/cable.c, src/tap/cable/wiggler.c,

@ -1279,17 +1279,22 @@ ft2232_connect( char *params[], cable_t *cable )
params_t *cable_params;
int result;
/* perform generic_usbconn_connect */
if ( ( result = generic_usbconn_connect( params, cable ) ) != 0 )
return result;
cable_params = (params_t *)malloc( sizeof(params_t) );
if (!cable_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
/* NOTE:
* Call the underlying usbport driver (*free) routine directly
* not generic_usbconn_free() since it also free's cable->params
* (which is not established) and cable (which the caller will do)
*/
cable->link.usb->driver->free( cable->link.usb );
return 4;
}
/* perform generic_usbconn_connect */
result = generic_usbconn_connect( params, cable );
if (result == 0)
{
cable_params->mpsse_frequency = 0;
cable_params->last_tdo_valid = 0;
@ -1298,9 +1303,8 @@ ft2232_connect( char *params[], cable_t *cable )
/* exchange generic cable parameters with our private parameter set */
free( cable->params );
cable->params = cable_params;
}
return result;
return 0;
}

@ -80,6 +80,7 @@ generic_parport_connect( char *params[], cable_t *cable )
cable_params = malloc( sizeof *cable_params );
if (!cable_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
parport_drivers[i]->parport_free( port );
return 4;
}

@ -145,12 +145,6 @@ generic_usbconn_connect( char *params[], cable_t *cable )
usbconn_t *conn = NULL;
int i;
cable_params = malloc( sizeof(generic_params_t) );
if (!cable_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
return 4;
}
if(strcasecmp(params[0], "usb") != 0)
{
user_specified.name = params[0];
@ -212,6 +206,13 @@ generic_usbconn_connect( char *params[], cable_t *cable )
return 2;
}
cable_params = malloc( sizeof(generic_params_t) );
if (!cable_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
usbconn_drivers[i]->free( conn );
return 4;
}
cable->link.usb = conn;
cable->params = cable_params;
cable->chain = NULL;

@ -57,17 +57,18 @@ jim_cable_connect( char *params[], cable_t *cable )
printf( _("JTAG target simulator JIM - work in progress!\n"));
s = jim_init();
s = jim_init();
if (!s) {
printf( _("Initialization failed.\n") );
return 3;
}
}
cable_params = malloc( sizeof(jim_cable_params_t) );
if (!cable_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
jim_free( s );
return 4;
}
}
cable->params = cable_params;
((jim_cable_params_t *)(cable->params))->s = s;

@ -75,6 +75,12 @@ usbblaster_connect( char *params[], cable_t *cable )
if (!cable_params)
{
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
/* NOTE:
* Call the underlying usbport driver (*free) routine directly
* not generic_usbconn_free() since it also free's cable->params
* (which is not established) and cable (which the caller will do)
*/
cable->link.usb->driver->free( cable->link.usb );
return 4;
}

@ -192,11 +192,6 @@ ep9307_connect( char *params[], cable_t *cable )
return 1;
}
if (cable->params != NULL) {
printf( _("Disconnecting %s\n"), _(cable->driver->description) );
cable->driver->disconnect( cable );
}
printf( _("Initializing Vision EP9307 SoM GPIO JTAG Cable\n") );
cable_params = malloc( sizeof *cable_params );

@ -191,6 +191,12 @@ wiggler_connect( char *params[], cable_t *cable )
wiggler_params = malloc( sizeof *wiggler_params );
if (!wiggler_params) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
/* NOTE:
* Call the underlying parport driver (*free) routine directly
* not generic_parconn_free() since it also free's cable->params
* (which is not established) and cable (which the caller will do)
*/
cable->link.port->driver->parport_free( cable->link.port );
return 4;
}
@ -198,13 +204,18 @@ wiggler_connect( char *params[], cable_t *cable )
free(cable->params);
cable->params = wiggler_params;
if ( ! param_bitmap )
param_bitmap = (char *)std_wgl_map;
if ( ( result = set_mapping( param_bitmap, cable ) ) != 0 ) {
printf( _("Pin mapping failed\n") );
free(cable->params);
/* NOTE:
* Call the underlying parport driver (*free) routine directly
* not generic_parconn_free() since it also free'scable (which
* the caller will do)
*/
cable->link.port->driver->parport_free( cable->link.port );
free( cable->params );
return result;
}

Loading…
Cancel
Save