From bcc72455d3ade257b825d1dd407fb84e821a5e06 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 22 May 2023 19:23:04 -0400 Subject: [PATCH] freebsd_network: Add missing NULL check in get_usb_device_attach_arg. May fix #18418. --- src/libs/compat/freebsd_network/usb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/compat/freebsd_network/usb.cpp b/src/libs/compat/freebsd_network/usb.cpp index 1fea0e9713..2b857aad0c 100644 --- a/src/libs/compat/freebsd_network/usb.cpp +++ b/src/libs/compat/freebsd_network/usb.cpp @@ -121,7 +121,7 @@ get_usb_device_attach_arg(struct freebsd_usb_device* device, struct usb_attach_a const usb_device_descriptor* device_desc = sUSB->get_device_descriptor(device->haiku_usb_device); - if (!device_desc) + if (device_desc == NULL) return B_BAD_VALUE; uaa->info.idVendor = device_desc->vendor_id; @@ -132,11 +132,13 @@ get_usb_device_attach_arg(struct freebsd_usb_device* device, struct usb_attach_a uaa->info.bDeviceProtocol = device_desc->device_protocol; const usb_configuration_info* config = sUSB->get_configuration(device->haiku_usb_device); - if (!device_desc) + if (device_desc == NULL) return B_BAD_VALUE; // TODO: represent more than just interface[0], but how? usb_interface_info* iface = config->interface[0].active; + if (iface == NULL) + return B_NO_INIT; uaa->info.bInterfaceClass = iface->descr->interface_class; uaa->info.bInterfaceSubClass = iface->descr->interface_subclass;