Memory leaks discovered by clang 3.1
Change-Id: I8a784ba9726deac508424eddb27e9c8409e2773f
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/795
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
case PAYLOAD_DIRECTION_OUT:
if (ulink_cmd->payload_out != NULL) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
case PAYLOAD_DIRECTION_OUT:
if (ulink_cmd->payload_out != NULL) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
return ERROR_FAIL;
} else {
ulink_cmd->payload_out = payload;
return ERROR_FAIL;
} else {
ulink_cmd->payload_out = payload;
case PAYLOAD_DIRECTION_IN:
if (ulink_cmd->payload_in_start != NULL) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
case PAYLOAD_DIRECTION_IN:
if (ulink_cmd->payload_in_start != NULL) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
return ERROR_FAIL;
} else {
ulink_cmd->payload_in_start = payload;
return ERROR_FAIL;
} else {
ulink_cmd->payload_in_start = payload;
if (scan_size_bits > (58 * 8)) {
LOG_ERROR("BUG: Tried to create CMD_SCAN_IO OpenULINK command with too"
" large payload");
if (scan_size_bits > (58 * 8)) {
LOG_ERROR("BUG: Tried to create CMD_SCAN_IO OpenULINK command with too"
" large payload");
+ if (ret != ERROR_OK) {
+ free(cmd);
/* Build payload_out that is common to all scan types */
cmd->payload_out[0] = scan_size_bytes & 0xFF;
/* Build payload_out that is common to all scan types */
cmd->payload_out[0] = scan_size_bytes & 0xFF;
/* CMD_CLOCK_TMS has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
/* CMD_CLOCK_TMS has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = count;
cmd->payload_out[1] = sequence;
cmd->payload_out[0] = count;
cmd->payload_out[1] = sequence;
/* CMD_CLOCK_TCK has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
/* CMD_CLOCK_TCK has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = count & 0xff;
cmd->payload_out[1] = (count >> 8) & 0xff;
cmd->payload_out[0] = count & 0xff;
cmd->payload_out[1] = (count >> 8) & 0xff;
/* CMD_GET_SIGNALS has two IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_IN);
/* CMD_GET_SIGNALS has two IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_IN);
+ if (ret != ERROR_OK) {
+ free(cmd);
return ulink_append_queue(device, cmd);
}
return ulink_append_queue(device, cmd);
}
/* CMD_SET_SIGNALS has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
/* CMD_SET_SIGNALS has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = low;
cmd->payload_out[1] = high;
cmd->payload_out[0] = low;
cmd->payload_out[1] = high;
/* CMD_SLEEP_US has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
/* CMD_SLEEP_US has two OUT payload bytes and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 2, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = us & 0x00ff;
cmd->payload_out[1] = (us >> 8) & 0x00ff;
cmd->payload_out[0] = us & 0x00ff;
cmd->payload_out[1] = (us >> 8) & 0x00ff;
/* CMD_CONFIGURE_TCK_FREQ has five OUT payload bytes and zero
* IN payload bytes */
ret = ulink_allocate_payload(cmd, 5, PAYLOAD_DIRECTION_OUT);
/* CMD_CONFIGURE_TCK_FREQ has five OUT payload bytes and zero
* IN payload bytes */
ret = ulink_allocate_payload(cmd, 5, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
if (delay_scan_in < 0)
cmd->payload_out[0] = 0;
if (delay_scan_in < 0)
cmd->payload_out[0] = 0;
/* CMD_SET_LEDS has one OUT payload byte and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 1, PAYLOAD_DIRECTION_OUT);
/* CMD_SET_LEDS has one OUT payload byte and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 1, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = led_state;
cmd->payload_out[0] = led_state;
/* CMD_TEST has one OUT payload byte and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 1, PAYLOAD_DIRECTION_OUT);
/* CMD_TEST has one OUT payload byte and zero IN payload bytes */
ret = ulink_allocate_payload(cmd, 1, PAYLOAD_DIRECTION_OUT);
+ if (ret != ERROR_OK) {
+ free(cmd);
cmd->payload_out[0] = 0xAA;
cmd->payload_out[0] = 0xAA;
ret = ulink_usb_open(&ulink_handle);
if (ret != ERROR_OK) {
LOG_ERROR("Could not open ULINK device");
ret = ulink_usb_open(&ulink_handle);
if (ret != ERROR_OK) {
LOG_ERROR("Could not open ULINK device");
+ free(ulink_handle);
+ ulink_handle = NULL;
ULINK_FIRMWARE_FILE, ULINK_RENUMERATION_DELAY);
if (ret != ERROR_OK) {
LOG_ERROR("Could not download firmware and re-numerate ULINK");
ULINK_FIRMWARE_FILE, ULINK_RENUMERATION_DELAY);
if (ret != ERROR_OK) {
LOG_ERROR("Could not download firmware and re-numerate ULINK");
+ free(ulink_handle);
+ ulink_handle = NULL;
/* Bulk IN transfer failed -> unrecoverable error condition */
LOG_ERROR("Cannot communicate with ULINK device. Disconnect ULINK from "
"the USB port and re-connect, then re-run OpenOCD");
/* Bulk IN transfer failed -> unrecoverable error condition */
LOG_ERROR("Cannot communicate with ULINK device. Disconnect ULINK from "
"the USB port and re-connect, then re-run OpenOCD");
+ free(ulink_handle);
+ ulink_handle = NULL;
return ERROR_FAIL;
}
#ifdef _DEBUG_USB_COMMS_
return ERROR_FAIL;
}
#ifdef _DEBUG_USB_COMMS_
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)