In the Linux kernel, the following vulnerability has been resolved:
net: hso: fix null-ptr-deref during tty device unregistration
Multiple ttys try to claim the same the minor number causing a double unregistration of the same device. The first unregistration succeeds but the next one results in a null-ptr-deref.
The getfreeserialindex() function returns an available minor number but doesn't assign it immediately. The assignment is done by the caller later. But before this assignment, calls to getfreeserialindex() would return the same minor number.
Fix this by modifying getfreeserialindex to assign the minor number immediately after one is found to be and rename it to obtainminor() to better reflect what it does. Similary, rename setserialbyindex() to releaseminor() and modify it to free up the minor number of the given hsoserial. Every obtainminor() should have corresponding release_minor() call.