diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 05adbf5505..7504d35cc0 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -481,9 +481,6 @@ device_attach(device_t device) || device->methods.attach == NULL) return B_ERROR; - // Always hold the giant lock during attach. - mtx_lock(&Giant); - result = device->methods.attach(device); if (result == 0) @@ -492,7 +489,6 @@ device_attach(device_t device) if (result == 0 && HAIKU_DRIVER_REQUIRES(FBSD_WLAN_FEATURE)) result = start_wlan(device); - mtx_unlock(&Giant); return result; } diff --git a/src/libs/compat/freebsd_network/driver.c b/src/libs/compat/freebsd_network/driver.c index 4eada982ff..762e392e9a 100644 --- a/src/libs/compat/freebsd_network/driver.c +++ b/src/libs/compat/freebsd_network/driver.c @@ -310,6 +310,9 @@ _fbsd_init_drivers() if (status < B_OK) goto err6; + // Always hold the giant lock during attach. + mtx_lock(&Giant); + for (int p = 0; sProbedDevices[p].bus != BUS_INVALID; p++) { device_t root, device = NULL; status = init_root_device(&root, sProbedDevices[p].bus); @@ -341,6 +344,8 @@ _fbsd_init_drivers() device_delete_child(NULL, root); } + mtx_unlock(&Giant); + if (gDeviceCount > 0) return B_OK;