mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Fix USB hotplug crash
Currently the SysFS node for USB devices is only initialized for USB hubs, which means it will cause a kernel crash upon being dereferenced in a non-hub device. This fixes the problem by making initialization happen for all USB devices.
This commit is contained in:
parent
11cb7c7b28
commit
4b1537387f
Notes:
sideshowbarker
2024-07-17 08:32:37 +09:00
Author: https://github.com/b14ckcat Commit: https://github.com/SerenityOS/serenity/commit/4b1537387f Pull-request: https://github.com/SerenityOS/serenity/pull/14703 Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 2 additions and 2 deletions
|
@ -20,6 +20,8 @@ ErrorOr<NonnullRefPtr<Device>> Device::try_create(USBController const& controlle
|
||||||
{
|
{
|
||||||
auto pipe = TRY(Pipe::try_create_pipe(controller, Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0));
|
auto pipe = TRY(Pipe::try_create_pipe(controller, Pipe::Type::Control, Pipe::Direction::Bidirectional, 0, 8, 0));
|
||||||
auto device = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Device(controller, port, speed, move(pipe))));
|
auto device = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Device(controller, port, speed, move(pipe))));
|
||||||
|
auto sysfs_node = TRY(SysFSUSBDeviceInformation::create(*device));
|
||||||
|
device->m_sysfs_device_info_node = move(sysfs_node);
|
||||||
TRY(device->enumerate_device());
|
TRY(device->enumerate_device());
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@ ErrorOr<void> Hub::enumerate_and_power_on_hub()
|
||||||
// USBDevice::enumerate_device must be called before this.
|
// USBDevice::enumerate_device must be called before this.
|
||||||
VERIFY(m_address > 0);
|
VERIFY(m_address > 0);
|
||||||
|
|
||||||
m_sysfs_device_info_node = TRY(SysFSUSBDeviceInformation::create(*this));
|
|
||||||
|
|
||||||
if (m_device_descriptor.device_class != USB_CLASS_HUB) {
|
if (m_device_descriptor.device_class != USB_CLASS_HUB) {
|
||||||
dbgln("USB Hub: Trying to enumerate and power on a device that says it isn't a hub.");
|
dbgln("USB Hub: Trying to enumerate and power on a device that says it isn't a hub.");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
Loading…
Reference in a new issue