- Don't call ExFreePool for null pointers

svn path=/trunk/; revision=43285
This commit is contained in:
Johannes Anderwald 2009-10-04 17:39:26 +00:00
parent 3c4ec53672
commit f04d450f1f

View file

@ -498,7 +498,8 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
goto cleanup; goto cleanup;
} }
RtlCopyMemory(NewBuffer, ReturnBuffer.Buffer, ReturnBuffer.Length); RtlCopyMemory(NewBuffer, ReturnBuffer.Buffer, ReturnBuffer.Length);
ExFreePool(ReturnBuffer.Buffer); if (ReturnBuffer.Buffer)
ExFreePool(ReturnBuffer.Buffer);
ReturnBuffer.Buffer = NewBuffer; ReturnBuffer.Buffer = NewBuffer;
} }
DPRINT("Adding symbolic link %wZ\n", &KeyName); DPRINT("Adding symbolic link %wZ\n", &KeyName);
@ -563,7 +564,7 @@ NextReferenceString:
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
cleanup: cleanup:
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status) && ReturnBuffer.Buffer)
ExFreePool(ReturnBuffer.Buffer); ExFreePool(ReturnBuffer.Buffer);
if (InterfaceKey != INVALID_HANDLE_VALUE) if (InterfaceKey != INVALID_HANDLE_VALUE)
ZwClose(InterfaceKey); ZwClose(InterfaceKey);
@ -573,9 +574,12 @@ cleanup:
ZwClose(ReferenceKey); ZwClose(ReferenceKey);
if (ControlKey != INVALID_HANDLE_VALUE) if (ControlKey != INVALID_HANDLE_VALUE)
ZwClose(ControlKey); ZwClose(ControlKey);
ExFreePool(DeviceBi); if (DeviceBi)
ExFreePool(ReferenceBi); ExFreePool(DeviceBi);
ExFreePool(bip); if (ReferenceBi)
ExFreePool(ReferenceBi);
if (bip)
ExFreePool(bip);
return Status; return Status;
} }
@ -888,7 +892,7 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject,
Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name); Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name);
if (!NT_SUCCESS(Status) && ReferenceString == NULL) if (!NT_SUCCESS(Status) && ReferenceString == NULL)
{ {
DPRINT("IoCreateSymbolicLink() failed with status 0x%08lx\n", Status); DPRINT1("IoCreateSymbolicLink() failed with status 0x%08lx\n", Status);
ZwClose(SubKey); ZwClose(SubKey);
ZwClose(InterfaceKey); ZwClose(InterfaceKey);
ZwClose(ClassKey); ZwClose(ClassKey);
@ -917,7 +921,7 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject,
SymbolicLinkName->Length); SymbolicLinkName->Length);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status); DPRINT1("ZwSetValueKey() failed with status 0x%08lx\n", Status);
ExFreePool(SymbolicLinkName->Buffer); ExFreePool(SymbolicLinkName->Buffer);
} }
else else
@ -973,7 +977,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
if (SymbolicLinkName == NULL) if (SymbolicLinkName == NULL)
return STATUS_INVALID_PARAMETER_1; return STATUS_INVALID_PARAMETER_1;
DPRINT("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable); DPRINT1("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable);
/* Symbolic link name is \??\ACPI#PNP0501#1#{GUID}\ReferenceString */ /* Symbolic link name is \??\ACPI#PNP0501#1#{GUID}\ReferenceString */
/* Get GUID from SymbolicLinkName */ /* Get GUID from SymbolicLinkName */
@ -981,7 +985,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
EndPosition = wcschr(SymbolicLinkName->Buffer, L'}'); EndPosition = wcschr(SymbolicLinkName->Buffer, L'}');
if (!StartPosition ||!EndPosition || StartPosition > EndPosition) if (!StartPosition ||!EndPosition || StartPosition > EndPosition)
{ {
DPRINT("IoSetDeviceInterfaceState() returning STATUS_INVALID_PARAMETER_1\n"); DPRINT1("IoSetDeviceInterfaceState() returning STATUS_INVALID_PARAMETER_1\n");
return STATUS_INVALID_PARAMETER_1; return STATUS_INVALID_PARAMETER_1;
} }
GuidString.Buffer = StartPosition; GuidString.Buffer = StartPosition;
@ -989,8 +993,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
SymLink.Buffer = SymbolicLinkName->Buffer; SymLink.Buffer = SymbolicLinkName->Buffer;
SymLink.MaximumLength = SymLink.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)SymLink.Buffer); SymLink.MaximumLength = SymLink.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)SymLink.Buffer);
DPRINT1("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable);
/* Get pointer to the PDO */ /* Get pointer to the PDO */
Status = IoGetDeviceObjectPointer( Status = IoGetDeviceObjectPointer(
&SymLink, &SymLink,
@ -999,7 +1002,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
&PhysicalDeviceObject); &PhysicalDeviceObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("IoGetDeviceObjectPointer() failed with status 0x%08lx\n", Status); DPRINT1("IoGetDeviceObjectPointer() failed with status 0x%08lx\n", Status);
return Status; return Status;
} }
@ -1012,7 +1015,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
(PVOID)SymbolicLinkName); (PVOID)SymbolicLinkName);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
DPRINT1("Status %x\n", Status);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }