Resolve SDV reported "defect"

NdisMGetDeviceProperty() should always return non-NULL
FunctionalDeviceObject according to _Outptr_opt_. An explicit
FunctionalDeviceObject NULL check has been added to keep the SDV happy
and not calling our driver "defective".

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-07-31 13:51:35 +02:00 committed by Jason A. Donenfeld
parent b666f587d5
commit afdbc75bf9
3 changed files with 5 additions and 1 deletions

View File

@ -51,6 +51,8 @@ msbuild wintun.proj [/t:<target>]
- `SDV`: Runs Static Driver Verifier, which includes a clean driver build, only for AMD64 release configuration. - `SDV`: Runs Static Driver Verifier, which includes a clean driver build, only for AMD64 release configuration.
- `SDVView`: Views the results of the Static Driver Verifier.
- `DVL`: Runs the `SDV`, and creates a Driver Verification Log, only for AMD64 release configurations. - `DVL`: Runs the `SDV`, and creates a Driver Verification Log, only for AMD64 release configurations.
- `MSM`: Builds Microsoft Installer Merge Modules in `<output folder>\wintun-<platform>-<version>.msm`. Requires WHQL signed driver. - `MSM`: Builds Microsoft Installer Merge Modules in `<output folder>\wintun-<platform>-<version>.msm`. Requires WHQL signed driver.

View File

@ -930,6 +930,8 @@ TunInitializeEx(
Ctx->MiniportAdapterHandle = MiniportAdapterHandle; Ctx->MiniportAdapterHandle = MiniportAdapterHandle;
NdisMGetDeviceProperty(MiniportAdapterHandle, NULL, &Ctx->FunctionalDeviceObject, NULL, NULL, NULL); NdisMGetDeviceProperty(MiniportAdapterHandle, NULL, &Ctx->FunctionalDeviceObject, NULL, NULL, NULL);
if (Status = NDIS_STATUS_FAILURE, !Ctx->FunctionalDeviceObject)
goto cleanupFreeCtx;
/* Reverse engineering indicates that we'd be better off calling /* Reverse engineering indicates that we'd be better off calling
* NdisWdfGetAdapterContextFromAdapterHandle(functional_device), * NdisWdfGetAdapterContextFromAdapterHandle(functional_device),
* which points to our TUN_CTX object directly, but this isn't * which points to our TUN_CTX object directly, but this isn't