Skip to content

Commit

Permalink
app: usb_hid: fix potential unbalanced lock
Browse files Browse the repository at this point in the history
  • Loading branch information
M1cha committed Oct 5, 2023
1 parent 5dd2e26 commit 87f1d18
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/usb_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ int zmk_usb_hid_send_report(const uint8_t *report, size_t len) {
case USB_DC_UNKNOWN:
return -ENODEV;
default:
k_sem_take(&hid_sem, K_MSEC(30));
int err = hid_int_ep_write(hid_dev, report, len, NULL);
int err = k_sem_take(&hid_sem, K_MSEC(30));
if (err) {
LOG_ERR("failed to take sem");
return err;
}

err = hid_int_ep_write(hid_dev, report, len, NULL);

if (err) {
k_sem_give(&hid_sem);
Expand Down

0 comments on commit 87f1d18

Please sign in to comment.