]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Jan 2015 14:14:08 +0000 (22:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Jan 2015 14:14:08 +0000 (22:14 +0800)
added patches:
gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch
gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch

queue-3.14/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch [new file with mode: 0644]
queue-3.14/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch [new file with mode: 0644]
queue-3.14/series

diff --git a/queue-3.14/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch b/queue-3.14/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch
new file mode 100644 (file)
index 0000000..aee5941
--- /dev/null
@@ -0,0 +1,55 @@
+From 5539b3c938d64a60cb1fc442ac3ce9263d52de0c Mon Sep 17 00:00:00 2001
+From: Johan Hovold <johan@kernel.org>
+Date: Mon, 12 Jan 2015 17:12:24 +0100
+Subject: gpio: fix memory and reference leaks in gpiochip_add error path
+
+From: Johan Hovold <johan@kernel.org>
+
+commit 5539b3c938d64a60cb1fc442ac3ce9263d52de0c upstream.
+
+Memory allocated and references taken by of_gpiochip_add and
+acpi_gpiochip_add were never released on errors in gpiochip_add (e.g.
+failure to find free gpio range).
+
+Fixes: 391c970c0dd1 ("of/gpio: add default of_xlate function if device
+has a node pointer")
+Fixes: 664e3e5ac64c ("gpio / ACPI: register to ACPI events
+automatically")
+
+Signed-off-by: Johan Hovold <johan@kernel.org>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpio/gpiolib.c |   11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+--- a/drivers/gpio/gpiolib.c
++++ b/drivers/gpio/gpiolib.c
+@@ -1222,6 +1222,9 @@ int gpiochip_add(struct gpio_chip *chip)
+       spin_unlock_irqrestore(&gpio_lock, flags);
++      if (status)
++              goto fail;
++
+ #ifdef CONFIG_PINCTRL
+       INIT_LIST_HEAD(&chip->pin_ranges);
+ #endif
+@@ -1229,12 +1232,12 @@ int gpiochip_add(struct gpio_chip *chip)
+       of_gpiochip_add(chip);
+       acpi_gpiochip_add(chip);
+-      if (status)
+-              goto fail;
+-
+       status = gpiochip_export(chip);
+-      if (status)
++      if (status) {
++              acpi_gpiochip_remove(chip);
++              of_gpiochip_remove(chip);
+               goto fail;
++      }
+       pr_debug("%s: registered GPIOs %d to %d on device: %s\n", __func__,
+               chip->base, chip->base + chip->ngpio - 1,
diff --git a/queue-3.14/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch b/queue-3.14/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch
new file mode 100644 (file)
index 0000000..beaede7
--- /dev/null
@@ -0,0 +1,43 @@
+From 7b8792bbdffdff3abda704f89c6a45ea97afdc62 Mon Sep 17 00:00:00 2001
+From: Hans Holmberg <hans.holmberg@intel.com>
+Date: Fri, 9 Jan 2015 09:40:43 +0100
+Subject: gpiolib: of: Correct error handling in of_get_named_gpiod_flags
+
+From: Hans Holmberg <hans.holmberg@intel.com>
+
+commit 7b8792bbdffdff3abda704f89c6a45ea97afdc62 upstream.
+
+of_get_named_gpiod_flags fails with -EPROBE_DEFER in cases
+where the gpio chip is available and the GPIO translation fails.
+
+This causes drivers to be re-probed erroneusly, and hides the
+real problem(i.e. the GPIO number being out of range).
+
+Signed-off-by: Hans Holmberg <hans.holmberg@intel.com>
+Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpio/gpiolib-of.c |   10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpio/gpiolib-of.c
++++ b/drivers/gpio/gpiolib-of.c
+@@ -44,8 +44,14 @@ static int of_gpiochip_find_and_xlate(st
+               return false;
+       ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
+-      if (ret < 0)
+-              return false;
++      if (ret < 0) {
++              /* We've found the gpio chip, but the translation failed.
++               * Return true to stop looking and return the translation
++               * error via out_gpio
++               */
++              gg_data->out_gpio = ERR_PTR(ret);
++              return true;
++       }
+       gg_data->out_gpio = gpio_to_desc(ret + gc->base);
+       return true;
index 837aaad8bb21f1f9cb47df9c0a3c47b7d7a7a162..7c7319483c7a6a831393314a37707d808e55fe82 100644 (file)
@@ -53,3 +53,5 @@ vfio-pci-fix-the-check-on-pci-device-type-in.patch
 drivers-net-cpsw-fix-multicast-flush-in-dual-emac-mode.patch
 ftrace-jprobes-x86-fix-conflict-between-jprobes-and-function-graph-tracing.patch
 nfsv4.1-fix-client-id-trunking-on-linux.patch
+gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch
+gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch