[PATCH 6.6 164/568] selftests/resctrl: Fix closing IMC fds on error and open-code R+W instead of loops