Skip to content

Commit

Permalink
Merge pull request #394 from xor-gate/st-probe-busy-segfault
Browse files Browse the repository at this point in the history
st-probe: Fix segfault when programmer is already busy
  • Loading branch information
texane committed Apr 7, 2016
2 parents 3ed1676 + 1c32fc0 commit 3cd9cbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/st-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ void stlink_print_info(stlink_t *sl)
{
const chip_params_t *params = NULL;

if (!sl)
return;

for (size_t n = 0; n < sizeof(sl->serial); n++)
printf("%02x", sl->serial[n]);
printf("\n");
Expand Down
2 changes: 2 additions & 0 deletions src/stlink-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ static inline void write_flash_cr_bker_pnb(stlink_t *sl, uint32_t n) {

void stlink_close(stlink_t *sl) {
DLOG("*** stlink_close ***\n");
if (!sl)
return;
sl->backend->close(sl);
free(sl);
}
Expand Down
3 changes: 3 additions & 0 deletions src/stlink-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
enum SCSI_Generic_Direction {SG_DXFER_TO_DEV=0, SG_DXFER_FROM_DEV=0x80};

void _stlink_usb_close(stlink_t* sl) {
if (!sl)
return;

struct stlink_libusb * const handle = sl->backend_data;
// maybe we couldn't even get the usb device?
if (handle != NULL) {
Expand Down

0 comments on commit 3cd9cbb

Please sign in to comment.