When we allocate an IRP and set the Irp->MdlAddress to a MDL
should we set Irp->MdlAddress = NULL before completing the IRP?

Re: set Irp->MdlAddress = NULL by G

G
Wed Feb 08 09:05:19 CST 2006

I don't think this is necessary. Are you facing any problem of pending IRPs
if you don't set the NULL?

--Raj

"Bajamani" <bajamani@hotmail.com> wrote in message
news:1139403771.803391.72860@g14g2000cwa.googlegroups.com...
> When we allocate an IRP and set the Irp->MdlAddress to a MDL
> should we set Irp->MdlAddress = NULL before completing the IRP?
>



Re: set Irp->MdlAddress = NULL by Eliyas

Eliyas
Wed Feb 08 09:49:01 CST 2006

If you allocate an IRP, you cannot call IoCompleteRequest on it. You have to
call IoFreeIrp to free it. You don't need to set the Irp->MdlAddress to
NULL. You call IoFreeMdl to free the MDL yourself.

Check out scenario 11 in http://support.microsoft.com/kb/326315/en-us.

-Eliyas



Re: set Irp->MdlAddress = NULL by Bajamani

Bajamani
Fri Feb 10 04:09:34 CST 2006

Ok consider the code snippet

BOOLEAN MakeRequest()
{
irp = IoBuildDeviceIoControlRequest(....);
if(!irp)
return FALSE;

//
// some code here
//

if(something goes wrong)
{
// cannot call IoFreeIrp for irp built
// with IoBuildDeviceIoControlRequest
IoCompleteRequest(irp,...);
return FALSE;
}

//
// some code here
//
}


IoFreeIrp was not called because irp was built with
IoBuildDeviceIoControlRequest. So to cleanup the irp
IoCompleteRequest was called. is it right?



Eliyas Yakub [MSFT] wrote:
> If you allocate an IRP, you cannot call IoCompleteRequest on it. You have to
> call IoFreeIrp to free it. You don't need to set the Irp->MdlAddress to
> NULL. You call IoFreeMdl to free the MDL yourself.
>
> Check out scenario 11 in http://support.microsoft.com/kb/326315/en-us.
>
> -Eliyas


Re: set Irp->MdlAddress = NULL by Eliyas

Eliyas
Fri Feb 10 16:32:16 CST 2006

That's right. I have never seen anybody doing it that way. Typically IRP
allocation is done just before IoCallDriver so you don't have to call
IoCompleteRequest on your own IRP.


--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx