if (*argv[3] == 0 || *endp != 0)
return -1;
+ /* Consistency checking */
+ if (offset + len > flash->size) {
+ printf("ERROR: attempting %s past flash size (%#x)\n",
+ argv[0], flash->size);
+ return 1;
+ }
+
buf = map_physmem(addr, len, MAP_WRBACK);
if (!buf) {
puts("Failed to map physical memory\n");
if (ret != 1)
return -1;
+ /* Consistency checking */
+ if (offset + len > flash->size) {
+ printf("ERROR: attempting %s past flash size (%#x)\n",
+ argv[0], flash->size);
+ return 1;
+ }
+
ret = spi_flash_erase(flash, offset, len);
if (ret) {
printf("SPI flash %s failed\n", argv[0]);