fix segfaults on device destroy

In the case you had a subchan with no other reference then the one
holded by the list, then the subchan reference count reached zero before
the next elements of the linked list was taken, which was leading to
garbage.

Ticket #5019.