jtag/drivers/cmsis_dap_usb_bulk: fix clang warning
commit43e1d60e77b7984e21a9250a530a34f64bab78c0
authorTomas Vanek <vanekt@fbl.cz>
Sun, 10 Dec 2023 14:03:46 +0000 (10 15:03 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 21 Jan 2024 21:26:03 +0000 (21 21:26 +0000)
tree17563766a028e130cdfd8e3f1436866b10c78a9c
parentea2e26f7d521f5755b4bfda7bf12d99650277421
jtag/drivers/cmsis_dap_usb_bulk: fix clang warning

Clang static analyzer warnings
"1st function call argument is an uninitialized value"
on the first libusb_free_transfer() parameter (lines 423, 424)
could turn into a real problem in a corner case:
If allocation of a libusb transfer struct fails, the pointers of not yet
allocated transfers remain uninitialized.

Use calloc() to zero whole struct cmsis_dap_backend_data.

Fixes: fd75e9e54270 (jtag/drivers/cmsis_dap_bulk: use asynchronous libusb transfer)
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I0e489757d82d10ed7416c5e8c215e1facc7f8093
Reviewed-on: https://review.openocd.org/c/openocd/+/8045
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/jtag/drivers/cmsis_dap_usb_bulk.c