Skip to content

Commit 1856a03

Browse files
vai-mikarkartben
authored andcommitted
drivers: gpio: shell: fix asan reported oob error
ASAN reports error with native_sim after "gpio info <TAB>": runtime error: index 1 out of bounds for type 'gpio_ctrl [1]' So, although the dev pointer was not used, don't even read it from out-of-bounds of gpio_list. Signed-off-by: Miika Karanki <[email protected]>
1 parent 972b54c commit 1856a03

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/gpio/gpio_shell.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,11 @@ static const char *gpio_device_name(const struct device *dev)
488488

489489
static void device_name_get(size_t idx, struct shell_static_entry *entry)
490490
{
491-
const struct device *dev = gpio_list[idx].dev;
492-
493491
if (idx >= ARRAY_SIZE(gpio_list)) {
494492
entry->syntax = NULL;
495493
return;
496494
}
497-
498-
entry->syntax = gpio_device_name(dev);
495+
entry->syntax = gpio_device_name(gpio_list[idx].dev);
499496
entry->handler = NULL;
500497
entry->help = "Device";
501498
entry->subcmd = gpio_list[idx].subcmd;

0 commit comments

Comments
 (0)