env: Early return from env_get_f() on NULL name

Test non-NULL name immediately, not in env_match().

Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 8d53579..063cc76 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -708,9 +708,6 @@
 
 static const char *env_match(const char *p, const char *s1)
 {
-	if (s1 == NULL || *s1 == '\0')
-		return NULL;
-
 	while (*s1 == *p++)
 		if (*s1++ == '=')
 			return p;
@@ -728,6 +725,9 @@
 {
 	const char *env, *p, *end;
 
+	if (name == NULL || *name == '\0')
+		return -1;
+
 	if (gd->env_valid == ENV_INVALID)
 		env = (const char *)default_environment;
 	else