diff options
author | b14ckcat <b14ckcat@protonmail.com> | 2022-07-26 21:35:35 -0400 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-07-27 05:52:35 +0000 |
commit | 4b1537387f0246c081fb96ceb974a63ea7f74c6a (patch) | |
tree | 4ba35ada8e33844ea331d1b414683682f0a336a0 /Kernel/Bus | |
parent | 11cb7c7b2807cb5bcc95c5853f909e441b8dec1b (diff) | |
download | serenity-4b1537387f0246c081fb96ceb974a63ea7f74c6a.zip |
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.
Diffstat (limited to 'Kernel/Bus')
-rw-r--r-- | Kernel/Bus/USB/USBDevice.cpp | 2 | ||||
-rw-r--r-- | Kernel/Bus/USB/USBHub.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Bus/USB/USBDevice.cpp b/Kernel/Bus/USB/USBDevice.cpp index 6309047e8a..1aa049dd50 100644 --- a/Kernel/Bus/USB/USBDevice.cpp +++ b/Kernel/Bus/USB/USBDevice.cpp @@ -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 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()); return device; } diff --git a/Kernel/Bus/USB/USBHub.cpp b/Kernel/Bus/USB/USBHub.cpp index fa9563d23d..8c0bf5e701 100644 --- a/Kernel/Bus/USB/USBHub.cpp +++ b/Kernel/Bus/USB/USBHub.cpp @@ -45,8 +45,6 @@ ErrorOr<void> Hub::enumerate_and_power_on_hub() // USBDevice::enumerate_device must be called before this. VERIFY(m_address > 0); - m_sysfs_device_info_node = TRY(SysFSUSBDeviceInformation::create(*this)); - 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."); return EINVAL; |