Index: src/drivers/driver_wext.c
===================================================================
--- src/drivers/driver_wext.c.orig
+++ src/drivers/driver_wext.c
@@ -54,12 +54,13 @@ int wpa_driver_wext_set_auth_param(struc
 	iwr.u.param.value = value;
 
 	if (ioctl(drv->ioctl_sock, SIOCSIWAUTH, &iwr) < 0) {
+		int saved_errno = errno;
 		if (errno != EOPNOTSUPP) {
 			wpa_printf(MSG_DEBUG, "WEXT: SIOCSIWAUTH(param %d "
 				   "value 0x%x) failed: %s)",
 				   idx, value, strerror(errno));
 		}
-		ret = errno == EOPNOTSUPP ? -2 : -1;
+		ret = saved_errno == EOPNOTSUPP ? -2 : -1;
 	}
 
 	return ret;
