stlink: avoid null pointer dereference in stlink_usb_close()

Otherwise it happens if stlink can not be opened on start.

Change-Id: I7088f10e61508dae230eccfe576a51498c92f5b8
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2550
Tested-by: jenkins
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Stian Skjelstad <stian@nixia.no>
__archive__
Paul Fertser 2015-02-15 21:37:16 +03:00
parent b4b1976e4e
commit d019080dfa
1 changed files with 4 additions and 4 deletions

View File

@ -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;
}