gpioc_detach: fix freeing of wrong pointers
MFC after: 1 week
(cherry picked from commit 3c6b59567f61277ed487320aa9ad130c6894ad7a)