Skip to content

Commit

Permalink
Merge tag 'gpio-fixes-for-v6.14-rc5' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/brgl/linux

Pull gpio fix from Bartosz Golaszewski:

 - fix a buggy get_direction() retval check

* tag 'gpio-fixes-for-v6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpiolib: Fix Oops in gpiod_direction_input_nonotify()
  • Loading branch information
Linus Torvalds committed Mar 2, 2025
2 parents ebb7d37 + 64407f4 commit 1973160
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ EXPORT_SYMBOL_GPL(gpiod_direction_input);

int gpiod_direction_input_nonotify(struct gpio_desc *desc)
{
int ret = 0;
int ret = 0, dir;

CLASS(gpio_chip_guard, guard)(desc);
if (!guard.gc)
Expand Down Expand Up @@ -2740,12 +2740,12 @@ int gpiod_direction_input_nonotify(struct gpio_desc *desc)
ret = guard.gc->direction_input(guard.gc,
gpio_chip_hwgpio(desc));
} else if (guard.gc->get_direction) {
ret = guard.gc->get_direction(guard.gc,
dir = guard.gc->get_direction(guard.gc,
gpio_chip_hwgpio(desc));
if (ret < 0)
return ret;
if (dir < 0)
return dir;

if (ret != GPIO_LINE_DIRECTION_IN) {
if (dir != GPIO_LINE_DIRECTION_IN) {
gpiod_warn(desc,
"%s: missing direction_input() operation and line is output\n",
__func__);
Expand All @@ -2764,7 +2764,7 @@ int gpiod_direction_input_nonotify(struct gpio_desc *desc)

static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
{
int val = !!value, ret = 0;
int val = !!value, ret = 0, dir;

CLASS(gpio_chip_guard, guard)(desc);
if (!guard.gc)
Expand All @@ -2788,12 +2788,12 @@ static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
} else {
/* Check that we are in output mode if we can */
if (guard.gc->get_direction) {
ret = guard.gc->get_direction(guard.gc,
dir = guard.gc->get_direction(guard.gc,
gpio_chip_hwgpio(desc));
if (ret < 0)
return ret;
if (dir < 0)
return dir;

if (ret != GPIO_LINE_DIRECTION_OUT) {
if (dir != GPIO_LINE_DIRECTION_OUT) {
gpiod_warn(desc,
"%s: missing direction_output() operation\n",
__func__);
Expand Down

0 comments on commit 1973160

Please sign in to comment.