gpiochip_get_desc() takes a u16 hwnum, but it turns out most users don't respect that and usually pass an unsigned int. Since implicit casting to a smaller type is dangerous - let's change the type of hwnum to unsigned int in gpiochip_get_desc() and in gpiochip_request_own_desc() where the size of hwnum is not respected either and who's a user of the former. This is safe as we then check the hwnum against the number of lines before proceeding in gpiochip_get_desc().
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -715,7 +715,8 @@ gpiochip_remove_pin_ranges(struct gpio_chip *chip) · 714 unmodified lines | |||
| 715 | 715 | ||
| 716 | #endif /* CONFIG_PINCTRL */ | 716 | #endif /* CONFIG_PINCTRL */ |
| 717 | 717 | ||
| 718 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | 718 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, |
| 719 | unsigned int hwnum, | ||
| 719 | const char *label, | 720 | const char *label, |
| 720 | enum gpio_lookup_flags lflags, | 721 | enum gpio_lookup_flags lflags, |
| 721 | enum gpiod_flags dflags); | 722 | enum gpiod_flags dflags); |