[Openvpn-devel,v1] tapctl: use delete_device() to remove a half-created adapter

Message ID 20261130221627.27132-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] tapctl: use delete_device() to remove a half-created adapter |

Commit Message

Gert Doering Nov. 30, 2026, 10:16 p.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

tap_create_adapter() open-coded delete_device() on its cleanup path.

Change-Id: I7e85442c6d7309b90e18a0ced7ae709b26c6dfc7
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2370
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2370
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
  

Patch

diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c
index a3d83e9..ffe7869 100644
--- a/src/tapctl/tap.c
+++ b/src/tapctl/tap.c
@@ -769,36 +769,7 @@ 
     if (dwResult != ERROR_SUCCESS)
     {
         /* The adapter was installed. But, the adapter ID was unobtainable. Clean-up. */
-        SP_REMOVEDEVICE_PARAMS removedevice_params = {
-            .ClassInstallHeader = {
-                .cbSize = sizeof(SP_CLASSINSTALL_HEADER),
-                .InstallFunction = DIF_REMOVE,
-            },
-            .Scope = DI_REMOVEDEVICE_GLOBAL,
-            .HwProfile = 0,
-        };
-
-        /* Set class installer parameters for DIF_REMOVE. */
-        if (SetupDiSetClassInstallParams(hDevInfoList, &devinfo_data,
-                                         &removedevice_params.ClassInstallHeader,
-                                         sizeof(SP_REMOVEDEVICE_PARAMS)))
-        {
-            /* Call appropriate class installer. */
-            if (SetupDiCallClassInstaller(DIF_REMOVE, hDevInfoList, &devinfo_data))
-            {
-                /* Check if a system reboot is required. */
-                check_reboot(hDevInfoList, &devinfo_data, pbRebootRequired);
-            }
-            else
-            {
-                msg(M_NONFATAL | M_ERRNO, "%s: SetupDiCallClassInstaller(DIF_REMOVE) failed",
-                    __FUNCTION__);
-            }
-        }
-        else
-        {
-            msg(M_NONFATAL | M_ERRNO, "%s: SetupDiSetClassInstallParams failed", __FUNCTION__);
-        }
+        delete_device(hDevInfoList, &devinfo_data, pbRebootRequired);
     }
 
 cleanup_hDevInfoList: