- dev = simple_strtoul(argv[1], NULL, 10);
- ack = simple_strtoul(argv[2], NULL, 10);
- part_num = simple_strtoul(argv[3], NULL, 10);
- access = simple_strtoul(argv[4], NULL, 10);
+ dev = simple_strtoul(argv[1], &end, 10);
+ if (dev < 0 || dev >= get_mmc_dev_count() || *end != '\0') {
+ printf("Invalid mmc device '%s'; should be [0..%u]\n",
+ argv[1], get_mmc_dev_count() - 1);
+ return CMD_RET_FAILURE;
+ }
+
+ ack = simple_strtoul(argv[2], &end, 10);
+ if (ack < 0 || ack > 1 || *end != '\0') {
+ printf("Invalid boot_ack value: %s\n", argv[2]);
+ return CMD_RET_FAILURE;
+ }
+
+ part_num = simple_strtoul(argv[3], &end, 10);
+ if (part_num < 0 || (part_num > 4 && part_num != 7) || *end != '\0') {
+ printf("Invalid part_num: %s\n", argv[3]);
+ return CMD_RET_FAILURE;
+ }
+
+ access = simple_strtoul(argv[4], &end, 10);
+ if (access < 0 || access > 7 || *end != '\0') {
+ printf("Invalid access value: %s\n", argv[4]);
+ return CMD_RET_FAILURE;
+ }