wpa_cli_cmd_interface_remove: Works! but...

Jouni Malinen jkmaline at cc.hut.fi
Tue Sep 5 23:50:11 EDT 2006

On Tue, Sep 05, 2006 at 11:03:20AM +0300, Adrian Nistor wrote:

> The issue is with the CoInitializeSecurity() call in ndis_events.c. It is
> done too many times during the lifetime of the wpa_supplicant process. MSDN
> says this call should be done only once during the lifetime of a process. A
> second call will fail with the error RPC_E_TOO_LATE. This is also visible in
> the log you supplied, look for the line:
>             1157393449.796875: CoInitializeSecurity() failed - returned
> 0x80010119       <----- aka RPC_E_TOO_LATE

> In ndis_events.c the static variable wmi_refcnt is used in order to avoid
> doing initializations of COM and WMI code too many times. Still this is not
> enough to ensure correctness, because after you remove all interfaces the
> counter drops to 0 again and a subsequent add_interface will re-do all the
> said initializations and call CoInitializeSecurity() again, which is wrong.
> It is ok to do the COM and WMI thing again, but not ok to re-do
> CoInitializeSecurity.

wmi_refcnt is used only to protect CoInitialize* part, not WMI setup.
Anyway, it was allow CoInitializeSecurity() to be called multiple times.

> I suggest to add a new flag to indicate if CoInitializeSecurity() was
> called, apart from the already existing wmi_refcnt variable.
> This small patch fixed the problem.
> Jouni, could you add this to the dev branch? Thank you!

No patch included, but this was a trivial change, so I just added a new
variable to allow CoInitializeSecurity() to be called once. I have not
tested this, but I'm assuming that it is still okay to call
CoUninitialize() follow by CoInitialize() and just skip
CoInitializeSecurity() in this case (e.g., when an adapter is removed
and added back).

Jouni Malinen                                            PGP id EFC895FA

More information about the HostAP mailing list