Skip to content

Commit

Permalink
fix -Werror=null-dereference warning
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Nov 3, 2023
1 parent 4b9320e commit 9377fd6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/host/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,12 @@ bool tuh_control_xfer (tuh_xfer_t* xfer) {

// Check if device is still connected (enumerating for dev0)
uint8_t const daddr = xfer->daddr;
if ( daddr == 0 && !_dev0.enumerating) return false;
if ( daddr != 0 && get_device(daddr)->connected == 0) return false;
if ( daddr == 0 ) {
if (!_dev0.enumerating) return false;
} else {
usbh_device_t const* dev = get_device(daddr);
if (dev && dev->connected == 0) return false;
}

// pre-check to help reducing mutex lock
TU_VERIFY(_ctrl_xfer.stage == CONTROL_STAGE_IDLE);
Expand Down

0 comments on commit 9377fd6

Please sign in to comment.