usb_hid: avoid destruction of used signal handler

Fixes #3945
This commit is contained in:
Alexander Boettcher 2020-11-10 14:09:58 +01:00 committed by Christian Helmuth
parent 87e90d640f
commit cd8b436566
2 changed files with 15 additions and 1 deletions

View File

@ -33,11 +33,14 @@ struct Driver
{
Lx::Task task;
Genode::Signal_handler<Task> handler;
bool handling_signal { false };
void handle_signal()
{
task.unblock();
handling_signal = true;
Lx::scheduler().schedule();
handling_signal = false;
}
template <typename... ARGS>
@ -56,6 +59,7 @@ struct Driver
Genode::Allocator_avl &alloc;
Task state_task;
Task urb_task;
Usb::Connection usb { env, &alloc, label.string(),
512 * 1024, state_task.handler };
usb_device * udev = nullptr;
@ -70,6 +74,7 @@ struct Driver
void unregister_device();
void probe_interface(usb_interface *, usb_device_id *);
void remove_interface(usb_interface *);
bool deinit();
};
struct Devices : Genode::List<Device::Le>

View File

@ -142,7 +142,14 @@ Driver::Device::Device(Driver & driver, Label label)
Driver::Device::~Device()
{
driver.devices.remove(&le);
}
bool Driver::Device::deinit()
{
if (udev) unregister_device();
return !udev && !state_task.handling_signal && !urb_task.handling_signal;
}
@ -228,7 +235,9 @@ void Driver::scan_report()
};
devices.for_each([&] (Device & d) {
if (!d.updated) destroy(heap, &d); });
if (!d.updated && d.deinit())
destroy(heap, &d);
});
}