Skip to content

Commit 430ca41

Browse files
James Courtier-DuttonJames Courtier-Dutton
authored andcommitted
Fix minor crash bugs with various console commands.
Signed-off-by: James Courtier-Dutton <james@superbug.co.uk>
1 parent 7fd5120 commit 430ca41

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

zephyr/program/framework/src/board_host_command.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ static int cmd_bbram(int argc, const char **argv)
540540
ram_addr = strtoi(argv[1], &e, 0);
541541
system_get_bbram(ram_addr, &bbram);
542542
CPRINTF("BBram%d: %d", ram_addr, bbram);
543+
} else {
544+
return EC_ERROR_PARAM_COUNT;
543545
}
544546

545547
return EC_SUCCESS;
@@ -554,6 +556,9 @@ static int cmd_memmap(int argc, const char **argv)
554556
int offset;
555557
char *e;
556558

559+
if (argc < 3) {
560+
return EC_ERROR_PARAM_COUNT;
561+
}
557562
if (argc > 3) {
558563
offset = strtoi(argv[2], &e, 0);
559564
data = strtoi(argv[3], &e, 0);

zephyr/program/framework/src/cypress_pd_common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,10 @@ static int cmd_cypd_get_status(int argc, const char **argv)
26572657
CPRINTS("PD%d INT value: %d", i, gpio_pin_get_dt(intr));
26582658
}
26592659

2660+
if (argc != 2) {
2661+
return EC_ERROR_PARAM_COUNT;
2662+
}
2663+
26602664
/* If a signal is specified, print only that one */
26612665
if (argc == 2) {
26622666
i = strtoi(argv[1], &e, 0);
@@ -2873,6 +2877,9 @@ static int cmd_pdwrite(int argc, const char **argv)
28732877
int controller, addr, data, rv;
28742878
char *e;
28752879

2880+
if (argc != 4) {
2881+
return EC_ERROR_PARAM_COUNT;
2882+
}
28762883
controller = strtoi(argv[1], &e, 0);
28772884
addr = strtoi(argv[2], &e, 0);
28782885
data = strtoi(argv[3], &e, 0);
@@ -2897,6 +2904,9 @@ static int cmd_pdread(int argc, const char **argv)
28972904
int controller, addr, data, rv;
28982905
char *e;
28992906

2907+
if (argc != 3) {
2908+
return EC_ERROR_PARAM_COUNT;
2909+
}
29002910
controller = strtoi(argv[1], &e, 0);
29012911
addr = strtoi(argv[2], &e, 0);
29022912

0 commit comments

Comments
 (0)