From: OpenOCD-Gerrit <ope...@us...> - 2020-06-06 17:06:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 061cae171c9d2b6015a565dcc748dd04319e08cf (commit) via f6b4079ce5793f86b2c26c6bfcc8c717e2c8a3c3 (commit) from 37330f89d789e5b0a74aa14f7a7bfcfb4260abff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 061cae171c9d2b6015a565dcc748dd04319e08cf Author: Antonio Borneo <bor...@gm...> Date: Fri May 22 18:08:55 2020 +0200 target/mem_ap: fix two memory leaks The target mem_ap misses the method 'deinit_target' and does not free the memory allocated during 'target create' and 'configure'. Add the missing method and free the allocated memory. Issue identified with valgrind. Change-Id: If0d0114a75dd76a8b65c2d46d96c6085fd31a09d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5700 Tested-by: jenkins diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c index 29cd37a90..ade48b6d7 100644 --- a/src/target/mem_ap.c +++ b/src/target/mem_ap.c @@ -65,6 +65,15 @@ static int mem_ap_init_target(struct command_context *cmd_ctx, struct target *ta return ERROR_OK; } +static void mem_ap_deinit_target(struct target *target) +{ + LOG_DEBUG("%s", __func__); + + free(target->private_config); + free(target->arch_info); + return; +} + static int mem_ap_arch_state(struct target *target) { LOG_DEBUG("%s", __func__); @@ -169,6 +178,7 @@ struct target_type mem_ap_target = { .target_create = mem_ap_target_create, .init_target = mem_ap_init_target, + .deinit_target = mem_ap_deinit_target, .examine = mem_ap_examine, .target_jim_configure = adiv5_jim_configure, commit f6b4079ce5793f86b2c26c6bfcc8c717e2c8a3c3 Author: Antonio Borneo <bor...@gm...> Date: Mon May 25 21:37:12 2020 +0200 libusb_helper: fix memory leak when no adapter is found When jtag_libusb_open() fails to find the adapter, it returns error but left libusb initialized causing memory leak of libusb internal data. Issue found with valgrind when no adapter or board is connected to the host, e.g. valgrind openocd -f board/st_nucleo_f4.cfg Close the libusb operations if jtag_libusb_open() has to return error. Change-Id: Ieb2f110be15705dafe80c099e7d83c07056c2a41 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5701 Tested-by: jenkins diff --git a/src/jtag/drivers/libusb_helper.c b/src/jtag/drivers/libusb_helper.c index fbbfb4114..184882abc 100644 --- a/src/jtag/drivers/libusb_helper.c +++ b/src/jtag/drivers/libusb_helper.c @@ -208,6 +208,9 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[], if (serial_mismatch) LOG_INFO("No device matches the serial string"); + if (retval != ERROR_OK) + libusb_exit(jtag_libusb_context); + return retval; } ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/libusb_helper.c | 3 +++ src/target/mem_ap.c | 10 ++++++++++ 2 files changed, 13 insertions(+) hooks/post-receive -- Main OpenOCD repository |