mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
gpiolib: sanitize the return value of gpio_chip::request()
The return value of the request() callback may be propagated to user-space. If a bad driver returns a positive number, it may confuse user programs. Tighten the API contract and check for positive numbers returned by GPIO controllers. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250210-gpio-sanitize-retvals-v1-2-12ea88506cb2@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
2d13f801f1
commit
69920338f8
|
|
@ -2349,6 +2349,8 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
|||
ret = guard.gc->request(guard.gc, offset);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
if (ret > 0)
|
||||
ret = -EBADE;
|
||||
if (ret)
|
||||
goto out_clear_bit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,8 @@ struct gpio_irq_chip {
|
|||
* @fwnode: optional fwnode providing this controller's properties
|
||||
* @owner: helps prevent removal of modules exporting active GPIOs
|
||||
* @request: optional hook for chip-specific activation, such as
|
||||
* enabling module power and clock; may sleep
|
||||
* enabling module power and clock; may sleep; must return 0 on success
|
||||
* or negative error number on failure
|
||||
* @free: optional hook for chip-specific deactivation, such as
|
||||
* disabling module power and clock; may sleep
|
||||
* @get_direction: returns direction for signal "offset", 0=out, 1=in,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user