Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st-probe: Fix segfault when programmer is already busy #394

Merged
merged 1 commit into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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