Skip to content

Commit

Permalink
Lock dmutex in graceful_suspend_resume
Browse files Browse the repository at this point in the history
  • Loading branch information
ollpu committed Jan 3, 2022
1 parent 54cbf56 commit 6498f32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/daemon/usb_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ static void graceful_suspend_resume() {
int drivers_attached = 1;
for (int i = 1; i < DEV_MAX; i++) {
usbdevice* kb = keyboard + i;
queued_mutex_lock(dmutex(kb));
if (kb->status == DEV_STATUS_CONNECTED && kb->active) {
for (int j = 0; j < kb->epcount; j++) {
// Replicates the logic from usbunclaim() - ignore
Expand All @@ -648,6 +649,7 @@ static void graceful_suspend_resume() {
}
}
}
queued_mutex_unlock(dmutex(kb));
}
if (drivers_attached) {
#ifndef NDEBUG
Expand All @@ -663,7 +665,8 @@ static void graceful_suspend_resume() {
// none), attemt to reclaim them.
for (int i = 1; i < DEV_MAX; i++) {
usbdevice* kb = keyboard + i;
if (kb->status == DEV_STATUS_CONNECTED) {
queued_mutex_lock(dmutex(kb));
if (kb->status == DEV_STATUS_CONNECTED && kb->active) {
int needs_reclaim = 0;
for (int j = 0; j < kb->epcount; j++) {
struct usbdevfs_getdriver query = {
Expand Down Expand Up @@ -693,6 +696,7 @@ static void graceful_suspend_resume() {
// try to reset the device.
}
}
queued_mutex_unlock(dmutex(kb));
}
}

Expand Down

0 comments on commit 6498f32

Please sign in to comment.