Avoid an infite loop by moving the number of retries before goto label. Also restore device attributes after changing these for probing. Related to Ticket #2433