Skip to content

Commit 92d2221

Browse files
committed
Merge tag 'gpio-fixes-for-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "Two fixes for the GPIO testing module and one commit making Andy a reviewer for the GPIO subsystem: - fix a memory corruption bug in gpio-sim - fix inconsistencies in user-space configuration of gpio-sim - make Andy Shevchenko a reviewer for the GPIO subsystem" * tag 'gpio-fixes-for-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: MAINTAINERS: add Andy Shevchenko as reviewer for the GPIO subsystem gpio: sim: quietly ignore configured lines outside the bank gpio: sim: fix memory corruption when adding named lines and unnamed hogs
2 parents 333a396 + d1f11f4 commit 92d2221

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8799,6 +8799,7 @@ F: include/linux/gpio/regmap.h
87998799
GPIO SUBSYSTEM
88008800
M: Linus Walleij <[email protected]>
88018801
M: Bartosz Golaszewski <[email protected]>
8802+
R: Andy Shevchenko <[email protected]>
88028803
88038804
S: Maintained
88048805
T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git

drivers/gpio/gpio-sim.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
696696
char **line_names;
697697

698698
list_for_each_entry(line, &bank->line_list, siblings) {
699+
if (line->offset >= bank->num_lines)
700+
continue;
701+
699702
if (line->name) {
700703
if (line->offset > max_offset)
701704
max_offset = line->offset;
@@ -721,8 +724,13 @@ static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
721724
if (!line_names)
722725
return ERR_PTR(-ENOMEM);
723726

724-
list_for_each_entry(line, &bank->line_list, siblings)
725-
line_names[line->offset] = line->name;
727+
list_for_each_entry(line, &bank->line_list, siblings) {
728+
if (line->offset >= bank->num_lines)
729+
continue;
730+
731+
if (line->name && (line->offset <= max_offset))
732+
line_names[line->offset] = line->name;
733+
}
726734

727735
return line_names;
728736
}
@@ -754,6 +762,9 @@ static int gpio_sim_add_hogs(struct gpio_sim_device *dev)
754762

755763
list_for_each_entry(bank, &dev->bank_list, siblings) {
756764
list_for_each_entry(line, &bank->line_list, siblings) {
765+
if (line->offset >= bank->num_lines)
766+
continue;
767+
757768
if (line->hog)
758769
num_hogs++;
759770
}
@@ -769,6 +780,9 @@ static int gpio_sim_add_hogs(struct gpio_sim_device *dev)
769780

770781
list_for_each_entry(bank, &dev->bank_list, siblings) {
771782
list_for_each_entry(line, &bank->line_list, siblings) {
783+
if (line->offset >= bank->num_lines)
784+
continue;
785+
772786
if (!line->hog)
773787
continue;
774788

0 commit comments

Comments
 (0)