From afdbc75bf9edfb7b292b5795b59553ecc0ef0926 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 31 Jul 2019 13:51:35 +0200 Subject: 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 --- README.md | 2 ++ wintun.c | 2 ++ wintun.proj | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a39fff4..7b06464 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ msbuild wintun.proj [/t:] - `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. - `MSM`: Builds Microsoft Installer Merge Modules in `\wintun--.msm`. Requires WHQL signed driver. diff --git a/wintun.c b/wintun.c index fae78bc..0dbd1dd 100644 --- a/wintun.c +++ b/wintun.c @@ -930,6 +930,8 @@ TunInitializeEx( Ctx->MiniportAdapterHandle = MiniportAdapterHandle; 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 * NdisWdfGetAdapterContextFromAdapterHandle(functional_device), * which points to our TUN_CTX object directly, but this isn't diff --git a/wintun.proj b/wintun.proj index 1370702..d5674e2 100644 --- a/wintun.proj +++ b/wintun.proj @@ -69,7 +69,7 @@ - + -- cgit v1.2.3-59-g8ed1b