Use of close_fd() in cleanup on failure exits is wrong; descriptor table is a shared data structure, and as soon as you've inserted a file reference there it is entirely possible for another thread to have move it around, replace it or remove it. Fortunately, not many places are using it that way; two of such are in amdgpu and AFAICS they are not hard to get rid of. Patches are in followups; review and testing would be very welcome - as it is, I've verified that they build, but that's about it.