diff --git a/arch/arm/plat-mxc/iomux-mx1-mx2.c b/arch/arm/plat-mxc/iomux-mx1-mx2.c
index a37163ce280b34824f4a901eb8e2e42230cb5521..25023ac2f53b9d8a35d2797beb6ee220ab6f710d 100644
--- a/arch/arm/plat-mxc/iomux-mx1-mx2.c
+++ b/arch/arm/plat-mxc/iomux-mx1-mx2.c
@@ -116,14 +116,16 @@ int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
 	int i;
 	unsigned gpio;
 	unsigned mode;
-	int ret = -EINVAL;
+	int ret;
 
 	for (i = 0; i < count; i++) {
 		gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK);
 		mode = *p & ~(GPIO_PIN_MASK | GPIO_PORT_MASK);
 
-		if (gpio >= (GPIO_PORT_MAX + 1) * 32)
+		if (gpio >= (GPIO_PORT_MAX + 1) * 32) {
+			ret = -EINVAL;
 			goto setup_error;
+		}
 
 		ret = gpio_request(gpio, label);
 		if (ret)