Fix for gcc 4.9.1

Change-Id: I0e92b06b1a2e7843828722411ffc574463c36730
diff --git a/arch/mips/brcmstb/memory.c b/arch/mips/brcmstb/memory.c
index 8998ce0..7ac3c24 100644
--- a/arch/mips/brcmstb/memory.c
+++ b/arch/mips/brcmstb/memory.c
@@ -774,7 +774,9 @@
 		off++;
 		if (off >= PTRS_PER_PTE) {
 			off = 0;
-			pte = consistent_pte[++idx];
+			idx++;
+			BUG_ON(idx < 0 || idx >= ARRAY_SIZE(consistent_pte));
+			pte = consistent_pte[idx];
 		}
 	} while (size -= PAGE_SIZE);
 
@@ -816,7 +818,9 @@
 		off++;
 		if (off >= PTRS_PER_PTE) {
 			off = 0;
-			pte = consistent_pte[++idx];
+			idx++;
+			BUG_ON(idx < 0 || idx >= ARRAY_SIZE(consistent_pte));
+			pte = consistent_pte[idx];
 		}
 		addr += PAGE_SIZE;
 	} while (addr < c->vm_end);