usb_modeswitch.cpp: fix use after free.
Signed-off-by: Adrien Destugues <[email protected]> Fixes #13185
This commit is contained in:
committed by
Adrien Destugues
parent
baf9ae1d47
commit
a1fdbe5bb2
@@ -531,11 +531,13 @@ my_device_added(usb_device newDevice, void **cookie)
|
|||||||
|
|
||||||
mutex_init(&device->lock, DRIVER_NAME " device lock");
|
mutex_init(&device->lock, DRIVER_NAME " device lock");
|
||||||
|
|
||||||
device->notify = create_sem(0, DRIVER_NAME " callback notify");
|
sem_id id = create_sem(0, DRIVER_NAME " callback notify");
|
||||||
if (device->notify < B_OK) {
|
if (id < B_OK) {
|
||||||
mutex_destroy(&device->lock);
|
mutex_destroy(&device->lock);
|
||||||
free(device);
|
free(device);
|
||||||
return device->notify;
|
return id;
|
||||||
|
} else {
|
||||||
|
device->notify = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&gDeviceListLock);
|
mutex_lock(&gDeviceListLock);
|
||||||
|
|||||||
Reference in New Issue
Block a user