coverity: uplink: Check getsockopt return code.
Removed some duplicate code by jumping to a common error handler.