android_kernel_samsung_msm8976/drivers/gpio
Johan Hovold a1f3ecb1f7 gpio: sysfs: fix memory leaks and device hotplug
commit 483d821108791092798f5d230686868112927044 upstream.

Unregister GPIOs requested through sysfs at chip remove to avoid leaking
the associated memory and sysfs entries.

The stale sysfs entries prevented the gpio numbers from being exported
when the gpio range was later reused (e.g. at device reconnect).

This also fixes the related module-reference leak.

Note that kernfs makes sure that any on-going sysfs operations finish
before the class devices are unregistered and that further accesses
fail.

The chip exported flag is used to prevent gpiod exports during removal.
This also makes it harder to trigger, but does not fix, the related race
between gpiochip_remove and export_store, which is really a race with
gpiod_request that needs to be addressed separately.

Also note that this would prevent the crashes (e.g. NULL-dereferences)
at reconnect that affects pre-3.18 kernels, as well as use-after-free on
operations on open attribute files on pre-3.14 kernels (prior to
kernfs).

Fixes: d8f388d8dc ("gpio: sysfs interface")
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>
2015-05-17 09:51:32 -07:00
..
Kconfig gpio: mcp23s08: Fix build error when CONFIG_SPI_MASTER=y && CONFIG_I2C=m 2013-05-20 19:16:16 +02:00
Makefile ARM: arm-soc platform updates for 3.10, part 2 2013-05-07 10:57:51 -07:00
devres.c
gpio-74x164.c gpio: 74x164: use spi_get_drvdata() and spi_set_drvdata() 2013-03-27 16:05:13 +01:00
gpio-adnp.c
gpio-adp5520.c gpio: adp5520: use devm_kzalloc() 2013-03-27 16:05:10 +01:00
gpio-adp5588.c
gpio-amd8111.c
gpio-arizona.c
gpio-bt8xx.c
gpio-clps711x.c
gpio-cs5535.c
gpio-da9052.c This is the MFD patch set for the 3.8 merge window. 2012-12-16 18:55:20 -08:00
gpio-da9055.c Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
gpio-davinci.c
gpio-em.c gpio: em: Make use of devm functions 2013-03-27 16:05:09 +01:00
gpio-ep93xx.c
gpio-ge.c
gpio-generic.c GPIO: gpio-generic: remove kfree() from bgpio_remove call 2013-04-11 19:33:54 +02:00
gpio-grgpio.c gpio: grgpio: Add irq support 2013-04-26 08:52:38 +02:00
gpio-ich.c GPIO changes for Linux 3.10 2013-05-06 15:40:55 -07:00
gpio-it8761e.c
gpio-janz-ttl.c
gpio-ks8695.c
gpio-langwell.c gpio-langwell: fix irq conflicts when DT is not used 2013-05-20 20:10:22 +02:00
gpio-lpc32xx.c Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
gpio-lynxpoint.c gpio/lynxpoint: check if the interrupt is enabled in IRQ handler 2013-11-04 04:31:06 -08:00
gpio-max730x.c
gpio-max732x.c gpio: max732x: use devm_kzalloc() 2013-03-27 16:05:11 +01:00
gpio-max7300.c gpio: max7300: use devm_kzalloc() 2013-03-27 16:05:11 +01:00
gpio-max7301.c MAX7301 GPIO: Do not force SPI speed when using OF Platform 2013-03-27 16:05:18 +01:00
gpio-mc9s08dz60.c
gpio-mc33880.c gpio: mc33880: use spi_get_drvdata() and spi_set_drvdata() 2013-03-27 16:05:14 +01:00
gpio-mcp23s08.c gpio: mcp23s08: convert driver to DT 2013-04-10 23:41:17 +02:00
gpio-ml-ioh.c gpio: Don't override the error code in probe error handling 2013-05-20 20:27:30 +02:00
gpio-mm-lantiq.c
gpio-mpc8xxx.c powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536 2013-12-11 22:36:27 -08:00
gpio-mpc5200.c
gpio-msic.c
gpio-msm-v1.c gpio: Make gpio-msm-v1 into a platform driver 2013-03-05 12:05:43 -08:00
gpio-msm-v2.c gpio: msm: Fix irq mask/unmask by writing bits instead of numbers 2014-01-09 12:24:24 -08:00
gpio-mvebu.c gpio: mvebu: make mvchip->irqbase signed for error handling 2013-12-04 10:55:50 -08:00
gpio-mxc.c arm: Move chained_irq_(enter|exit) to a generic file 2013-03-26 16:11:43 +00:00
gpio-mxs.c gpio: mxs: Allow for recursive enable_irq_wake() call 2014-05-13 13:59:45 +02:00
gpio-omap.c gpio/omap: auto-setup a GPIO when used as an IRQ 2013-10-13 16:08:31 -07:00
gpio-palmas.c gpio: palmas: Add support for Palmas GPIO 2013-02-14 00:22:45 +01:00
gpio-pca953x.c GPIO changes for Linux 3.10 2013-05-06 15:40:55 -07:00
gpio-pcf857x.c gpio: pcf857x: use devm_kzalloc() 2013-03-27 16:05:12 +01:00
gpio-pch.c gpio: Don't override the error code in probe error handling 2013-05-20 20:27:30 +02:00
gpio-pl061.c gpio: pl061: move irqdomain initialization 2013-12-04 10:57:20 -08:00
gpio-pxa.c GPIO changes for Linux 3.10 2013-05-06 15:40:55 -07:00
gpio-rc5t583.c
gpio-rcar.c gpio-rcar: R-Car GPIO IRQ share interrupt 2014-01-15 15:28:45 -08:00
gpio-rdc321x.c
gpio-sa1100.c
gpio-samsung.c GPIO changes for Linux 3.10 2013-05-06 15:40:55 -07:00
gpio-sch.c gpio: Don't override the error code in probe error handling 2013-05-20 20:27:30 +02:00
gpio-sodaville.c
gpio-spear-spics.c gpio: Convert to devm_ioremap_resource() 2013-01-22 11:41:56 -08:00
gpio-sta2x11.c
gpio-stmpe.c gpio: stmpe: pass DT node to irqdomain 2013-03-27 11:21:52 +01:00
gpio-stp-xway.c gpio: gpio-stp-xway.c: fix checkpatch error 2013-03-27 16:05:16 +01:00
gpio-sx150x.c
gpio-tc3589x.c gpio: gpio-tc3589x.c: fix checkpatch errors 2013-03-27 16:05:17 +01:00
gpio-tegra.c drivers/gpio: don't check resource with devm_ioremap_resource 2013-05-18 11:55:19 +02:00
gpio-timberdale.c gpio: gpio-timberdale.c: fix checkpatch error 2013-03-27 16:05:17 +01:00
gpio-tnetv107x.c
gpio-tps6586x.c This is the MFD patch set for the 3.8 merge window. 2012-12-16 18:55:20 -08:00
gpio-tps65910.c gpio: gpio-tps65910.c: fix checkpatch error 2013-03-27 16:05:18 +01:00
gpio-tps65912.c gpio: tps65912: fix wrong container_of arguments 2015-03-06 14:40:52 -08:00
gpio-ts5500.c Drivers: misc: remove __dev* attributes. 2013-01-03 15:57:16 -08:00
gpio-twl4030.c gpio: twl4030: Fix regression for twl gpio LED output 2014-01-09 12:24:24 -08:00
gpio-twl6040.c
gpio-ucb1400.c mfd: ucb1400: Pass ucb1400-gpio data through ac97 bus 2013-04-19 00:40:07 +02:00
gpio-viperboard.c gpio: Don't override the error code in probe error handling 2013-05-20 20:27:30 +02:00
gpio-vr41xx.c
gpio-vx855.c
gpio-wm831x.c
gpio-wm8350.c
gpio-wm8994.c
gpio-xilinx.c
gpiolib-acpi.c gpiolib-acpi: introduce acpi_get_gpio_by_index() helper 2013-04-12 00:31:18 +02:00
gpiolib-of.c gpio: squelch a compiler warning 2015-02-05 22:35:40 -08:00
gpiolib.c gpio: sysfs: fix memory leaks and device hotplug 2015-05-17 09:51:32 -07:00