I have written a system extension using DriverKit and USBDriverKit that seems to work well (running with developer mode on, SIP off, ... still waiting for entitlements).
When I plug my USB device and in terminal I type ioreg | grep com.myinc.mydriver I see one entry:
+-o IOUserServer(com.myinc.mydriver ... registered, matched, active, busy 0 (0ms), retain 13
I unplug the device and do another ioreg and I get the same but with retain 9.
If I plug my device, then another ioreg now shows 2 entries (the previous one and a new one).
Is this normal? Why is the previous one still active?
In my dext I check that my Stop and free functions are called and I cannot think of anything I have missed.
Can someone please explain this to me or point me toward what I may have forgotten to do? Does retain 9 have anything to do with what I do in my code?
I figured out my problem and will leave an answer here in case it helps someone else...
I obtained my
IOUSBHostInterfaceobject usingCopyInterface()(fromIOUSBHostDevice). Then on this object I calledOpen().In my
Stop()implementation I calledClose()on my interface object but I forgot to callrelease.Now when I disconnect my device, once all my
free()functions are called, in the console I get the message "no service left, exiting".