From 577850e82a8bec849b3e2d63c5e588b361679af0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 25 Jan 2015 22:14:16 +0800 Subject: [PATCH] 3.10-stable patches 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 --- ...nce-leaks-in-gpiochip_add-error-path.patch | 55 +++++++++++++++++++ ...handling-in-of_get_named_gpiod_flags.patch | 43 +++++++++++++++ queue-3.10/series | 2 + 3 files changed, 100 insertions(+) create mode 100644 queue-3.10/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch create mode 100644 queue-3.10/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch diff --git a/queue-3.10/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch b/queue-3.10/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch new file mode 100644 index 00000000000..02bf3341aae --- /dev/null +++ b/queue-3.10/gpio-fix-memory-and-reference-leaks-in-gpiochip_add-error-path.patch @@ -0,0 +1,55 @@ +From 5539b3c938d64a60cb1fc442ac3ce9263d52de0c Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 12 Jan 2015 17:12:24 +0100 +Subject: gpio: fix memory and reference leaks in gpiochip_add error path + +From: Johan Hovold + +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 +Signed-off-by: Linus Walleij +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpio/gpiolib.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -1214,6 +1214,9 @@ int gpiochip_add(struct gpio_chip *chip) + } + } + ++ if (status) ++ goto fail; ++ + #ifdef CONFIG_PINCTRL + INIT_LIST_HEAD(&chip->pin_ranges); + #endif +@@ -1223,12 +1226,12 @@ int gpiochip_add(struct gpio_chip *chip) + unlock: + spin_unlock_irqrestore(&gpio_lock, flags); + +- if (status) +- goto fail; +- + status = gpiochip_export(chip); +- if (status) ++ if (status) { ++ acpi_gpiochip_remove(chip); ++ of_gpiochip_remove(chip); + goto fail; ++ } + + pr_debug("gpiochip_add: registered GPIOs %d to %d on device: %s\n", + chip->base, chip->base + chip->ngpio - 1, diff --git a/queue-3.10/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch b/queue-3.10/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch new file mode 100644 index 00000000000..bf2e482711c --- /dev/null +++ b/queue-3.10/gpiolib-of-correct-error-handling-in-of_get_named_gpiod_flags.patch @@ -0,0 +1,43 @@ +From 7b8792bbdffdff3abda704f89c6a45ea97afdc62 Mon Sep 17 00:00:00 2001 +From: Hans Holmberg +Date: Fri, 9 Jan 2015 09:40:43 +0100 +Subject: gpiolib: of: Correct error handling in of_get_named_gpiod_flags + +From: Hans Holmberg + +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 +Reviewed-by: Alexandre Courbot +Signed-off-by: Linus Walleij +Signed-off-by: Greg Kroah-Hartman + +--- + 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 +@@ -42,8 +42,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 = ret + gc->base; + return true; diff --git a/queue-3.10/series b/queue-3.10/series index 7283bbeb88d..c3c0d675d18 100644 --- a/queue-3.10/series +++ b/queue-3.10/series @@ -22,3 +22,5 @@ uvcvideo-fix-destruction-order-in-uvc_delete.patch vfio-pci-fix-the-check-on-pci-device-type-in.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 -- 2.47.3