From d019080dfaa6c0c49228ecec2ad0c585ac65cb73 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Sun, 15 Feb 2015 21:37:16 +0300 Subject: [PATCH] stlink: avoid null pointer dereference in stlink_usb_close() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Otherwise it happens if stlink can not be opened on start. Change-Id: I7088f10e61508dae230eccfe576a51498c92f5b8 Signed-off-by: Paul Fertser Reviewed-on: http://openocd.zylin.com/2550 Tested-by: jenkins Reviewed-by: Andreas Färber Reviewed-by: Spencer Oliver Reviewed-by: Stian Skjelstad --- src/jtag/drivers/stlink_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 4959f97c..554ffc1e 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -1664,14 +1664,14 @@ static int stlink_speed(void *handle, int khz, bool query) } /** */ -static int stlink_usb_close(void *fd) +static int stlink_usb_close(void *handle) { - struct stlink_usb_handle_s *h = fd; + struct stlink_usb_handle_s *h = handle; - if (h->fd) + if (h && h->fd) jtag_libusb_close(h->fd); - free(fd); + free(h); return ERROR_OK; } -- 2.39.5