USB: Add nullpointer checks to USB Device destructor
It seems to be possible that in case of USB issues a Device is destroyed before it is registered with the device manager. In such a case fNode of the device is NULL and there is a page fault followed by a panic. Fixes #18922. Change-Id: I0a363a0ff85e6a74788701738e0cb85a90e99a05 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7821 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
722d3c01b7
commit
922624afa6
@@ -341,10 +341,12 @@ Device::~Device()
|
|||||||
// though, since we may be deleted because the device was unplugged already.
|
// though, since we may be deleted because the device was unplugged already.
|
||||||
Unconfigure(false);
|
Unconfigure(false);
|
||||||
|
|
||||||
status_t error = gDeviceManager->unregister_node(fNode);
|
if (fNode != NULL) {
|
||||||
if (error != B_OK && error != B_BUSY)
|
status_t error = gDeviceManager->unregister_node(fNode);
|
||||||
TRACE_ERROR("failed to unregister device node\n");
|
if (error != B_OK && error != B_BUSY)
|
||||||
fNode = NULL;
|
TRACE_ERROR("failed to unregister device node\n");
|
||||||
|
fNode = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy all Interfaces in the Configurations hierarchy.
|
// Destroy all Interfaces in the Configurations hierarchy.
|
||||||
for (int32 i = 0; fConfigurations != NULL
|
for (int32 i = 0; fConfigurations != NULL
|
||||||
|
|||||||
Reference in New Issue
Block a user