Some problems when I get the actual name of the device object

There are some codes of my driver where mounting volume:
//
// Open the symbolic link
//
IntializeObjectAttributes(&Attr, &Temp, OBJ_CASE_INSENSITIVE, 0, NULL);
Status = ZwOpenSymbolicLinkObject(&LinkHandle,SYMBOLIC_LINK_QUERY,&Attr);
if(!NT_SUCCESS(Status))
{
KdPrint((“failed to open sym link %wZ, error %08lX\n”,&Temp,Status));
return(NULL);
}

//
// Get the size of the buffer needed.
//
RtlZeroMemory(&Temp, sizeof(Temp));
Status = ZwQuerySymbolicLinkObject(LinkHandle, &Temp, &Length);
if(!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL)
{
KdPrint((“failed to query sym link %wZ, error %08lX\n”,&Temp,Status));
ZwClose(LinkHandle);
return(NULL);
}

//
// Allocate buffer of sufficient length
//
LinkTarget.Buffer = ExAllocatePool(NonPagedPool, Length + sizeof(WCHAR));
if(!LinkTarget.Buffer)
{
KdPrint((“PLEASE, buy more memory\n”));
ZwClose(LinkHandle);
return(NULL);
}

LinkTarget.Length = (USHORT)Length;
LinkTarget.MaximumLength = (USHORT)Length;

//
// Now get the actual name of the device object and close the shop
//
Status = ZwQuerySymbolicLinkObject(LinkHandle, &LinkTarget, &Length);
ZwClose(LinkHandle);
if(!NT_SUCCESS(Status))
{
KdPrint((“failed to query sym link %wZ second time, error %08lX\n”,
&Temp,Status));
if (LinkTarget.Buffer)
{
ExFreePool(LinkTarget.Buffer);
}

return(NULL);
}

The process can get the actual name of the device object successfully in genera.But when I change partition table, it fails. I want to known where the problem is.Thank you!