mm/madvise: reduce code duplication in error handling paths