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