--- /dev/null
+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,
--- /dev/null
+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;
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