[GIT PULL v1 6/7] stm class: Fix an endless loop in channel allocation