[PATCH 4.9 27/33] futex: Remove duplicated code and fix undefined behaviour