diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-10-12 18:44:42 +0000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-10-12 18:55:24 +0000 |
commit | d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663 (patch) | |
tree | 49461a6113fff49ecfb947a602d95ee91a373d2d /api/driver.c | |
parent | api: rewrite based on SwDevice (diff) | |
download | wintun-d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663.tar.xz wintun-d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663.zip |
driver: automatically close long-lived handle
There's only one handle that's likely to be open in a long lived way:
the tun registration handle. So we can force that closed automatically
when the device is about to close, if it's been improperly left open.
Other handles will indeed hold up closing, but if those exist, they're a
sign of a larger bug elsewhere that should be addressed. On the other
hand, tun registration handles might legitimately be open during driver
upgrades. This also saves us the trouble of dereferencing a freed
FileObject as in the general case.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'api/driver.c')
-rw-r--r-- | api/driver.c | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/api/driver.c b/api/driver.c index 3fb4909..172749f 100644 --- a/api/driver.c +++ b/api/driver.c @@ -69,10 +69,6 @@ DisableAllOurAdapters(_In_ HDEVINFO DevInfo, _Inout_ SP_DEVINFO_DATA_LIST **Disa ((Status & DN_HAS_PROBLEM) && ProblemCode == CM_PROB_DISABLED)) goto cleanupDeviceNode; - LOG(WINTUN_LOG_INFO, L"Force closing adapter \"%s\" open handles", Name); - if (!AdapterForceCloseHandles(DevInfo, &DeviceNode->Data)) - LOG(WINTUN_LOG_WARN, L"Failed to force close adapter \"%s\" open handles", Name); - LOG(WINTUN_LOG_INFO, L"Disabling adapter \"%s\"", Name); if (!AdapterDisableInstance(DevInfo, &DeviceNode->Data)) { |