diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 2186205a1a591e8303dcc6a1881b3fcd709eb02b..9f8d5319596d2a171f55035683c1eca61af21d11 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -202,6 +202,37 @@ int _do_setenv (int flag, int argc, char *argv[])
 			break;
 	}
 
+	/* Check for console redirection */
+	if (strcmp(name,"stdin") == 0) {
+		console = stdin;
+	} else if (strcmp(name,"stdout") == 0) {
+		console = stdout;
+	} else if (strcmp(name,"stderr") == 0) {
+		console = stderr;
+	}
+
+	if (console != -1) {
+		if (argc < 3) {		/* Cannot delete it! */
+			printf("Can't delete \"%s\"\n", name);
+			return 1;
+		}
+
+#ifdef CONFIG_CONSOLE_MUX
+		i = iomux_doenv(console, argv[2]);
+		if (i)
+			return i;
+#else
+		/* Try assigning specified device */
+		if (console_assign (console, argv[2]) < 0)
+			return 1;
+
+#ifdef CONFIG_SERIAL_MULTI
+		if (serial_assign (argv[2]) < 0)
+			return 1;
+#endif
+#endif /* CONFIG_CONSOLE_MUX */
+	}
+
 	/*
 	 * Delete any existing definition
 	 */
@@ -229,37 +260,6 @@ int _do_setenv (int flag, int argc, char *argv[])
 		}
 #endif
 
-		/* Check for console redirection */
-		if (strcmp(name,"stdin") == 0) {
-			console = stdin;
-		} else if (strcmp(name,"stdout") == 0) {
-			console = stdout;
-		} else if (strcmp(name,"stderr") == 0) {
-			console = stderr;
-		}
-
-		if (console != -1) {
-			if (argc < 3) {		/* Cannot delete it! */
-				printf("Can't delete \"%s\"\n", name);
-				return 1;
-			}
-
-#ifdef CONFIG_CONSOLE_MUX
-			i = iomux_doenv(console, argv[2]);
-			if (i)
-				return i;
-#else
-			/* Try assigning specified device */
-			if (console_assign (console, argv[2]) < 0)
-				return 1;
-
-#ifdef CONFIG_SERIAL_MULTI
-			if (serial_assign (argv[2]) < 0)
-				return 1;
-#endif
-#endif /* CONFIG_CONSOLE_MUX */
-		}
-
 		/*
 		 * Switch to new baudrate if new baudrate is supported
 		 */