[channels,serial] delay IRP thread start
wait until irp_thread_func has completed before starting the thread. This prevents a race condition when accessing the IRP structure which is freed up once the thread terminates.
This commit is contained in:
parent
9f911bea62
commit
348ddf61c0
@ -671,7 +671,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
|
||||
data->serial = serial;
|
||||
data->irp = irp;
|
||||
/* data freed by irp_thread_func */
|
||||
irpThread = CreateThread(NULL, 0, irp_thread_func, (void*)data, 0, NULL);
|
||||
irpThread = CreateThread(NULL, 0, irp_thread_func, (void*)data, CREATE_SUSPENDED, NULL);
|
||||
|
||||
if (irpThread == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -687,8 +687,12 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp)
|
||||
goto error_handle;
|
||||
}
|
||||
|
||||
ResumeThread(irpThread);
|
||||
|
||||
return;
|
||||
error_handle:
|
||||
if (irpThread)
|
||||
CloseHandle(irpThread);
|
||||
irp->IoStatus = STATUS_NO_MEMORY;
|
||||
irp->Complete(irp);
|
||||
free(data);
|
||||
|
Loading…
Reference in New Issue
Block a user