diff --git a/src/flash/davinci_nand.c b/src/flash/davinci_nand.c
index ffd35608df18b6fe2ee5d8fda292151070fb544e..29c963005098b249ce21be51d778e850f32e1548 100644
--- a/src/flash/davinci_nand.c
+++ b/src/flash/davinci_nand.c
@@ -663,7 +663,7 @@ static int davinci_nand_device_command(struct command_context_s *cmd_ctx,
 	}
 
 	aemif = strtoul(argv[4], &ep, 0);
-	if (*ep || chip == 0 || chip == ULONG_MAX) {
+	if (*ep || aemif == 0 || aemif == ULONG_MAX) {
 		LOG_ERROR("Invalid AEMIF controller address %s", argv[4]);
 		goto fail;
 	}