I have Linux machine (ARM based, built using Yocto, kernel 4.10) with modem connected using USB interface. Modem can be powered up or down using GPIO lines.
After powering modem, CDC device file is showing up. I can communicate with modem without problem.
Sometimes I have to reset modem, so I close all communication with device file, power down using GPIO, and after couple of seconds switching power back on.
And here is the problem, device file is created, but with new filename. Instead, lets say /dev/ttyACM5, I got /dev/ttyACM6.
While I can get new filename from system, I'm worried about resource leaks.
First I suspected error in my program, but after hours of testing I'm pretty confident, that my program is not a problem.
Here are some facts, that may help:
Filename is locked when program that communicated with CDC device is running. After program exit - device filename is freed.
When my program opens, but do not communicate with CDC device - filename is not locked. (after modem power down, and up /dev/ttyACM5 device file shows up)
When my program open, and do communicate with CDC device - after power down dmesg shows message "cdc_acm 1-3:1.10: failed to set dtr/rts" and filename is locked until my program exits.