Factorize release_buffer()