From 75a4dfe4a1724ab22f85f42e853b8c68288ccd88 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 12 Nov 2024 21:52:02 -0500 Subject: [PATCH] USB: Add a missing NULL check in Hub constructor. This case is probably very rare, though. --- src/add-ons/kernel/bus_managers/usb/Hub.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/usb/Hub.cpp b/src/add-ons/kernel/bus_managers/usb/Hub.cpp index 6a85ebc409..e335e09054 100644 --- a/src/add-ons/kernel/bus_managers/usb/Hub.cpp +++ b/src/add-ons/kernel/bus_managers/usb/Hub.cpp @@ -69,14 +69,15 @@ Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort, usb_interface_list *list = Configuration()->interface; Object *object = GetStack()->GetObject(list->active->endpoint[0].handle); - if (object && (object->Type() & USB_OBJECT_INTERRUPT_PIPE) != 0) { + if (object != NULL && (object->Type() & USB_OBJECT_INTERRUPT_PIPE) != 0) { fInterruptPipe = (InterruptPipe *)object; fInterruptPipe->QueueInterrupt(fInterruptStatus, sizeof(fInterruptStatus), InterruptCallback, this); } else { TRACE_ALWAYS("no interrupt pipe found\n"); } - object->ReleaseReference(); + if (object != NULL) + object->ReleaseReference(); // Wait some time before powering up the ports if (!isRootHub)