Commit a3bd7efb authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Benjamin Cabé
Browse files

gpio: shell: fix a crash where there's less line names than gpios

Don't try to dereference line_names if the index is beyond
line_names_len, this can happen if there's less line names than the
total amount of supported gpios specified.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 323b0d8c
Loading
Loading
Loading
Loading
+1 −1
Changes for drivers/gpio/gpio_shell.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ static int get_gpio_pin(const struct shell *sh, const struct gpio_ctrl *ctrl, ch
	gpio_pin_t i;
	int result;

	for (i = 0; i < ctrl->ngpios; i++) {
	for (i = 0; i < ctrl->ngpios && i < ctrl->line_names_len; i++) {
		result = line_cmp(line_name, ctrl->line_names[i]);
		if (result == 0) {
			if ((BIT64(i) & ctrl->reserved_mask) != 0) {