OSDN Git Service

gpio: sysfs: fix gpio device-attribute leak
authorJohan Hovold <johan@kernel.org>
Tue, 13 Jan 2015 12:00:05 +0000 (13:00 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 15 Jan 2015 16:20:15 +0000 (17:20 +0100)
commit0915e6feb38de8d3601819992a5bd050201a56fa
tree246c1724e7a827583fa70147869b4bcbb15b883c
parent121b6a79955a3a3fd7bbb9b8cb88d5b9dad6283d
gpio: sysfs: fix gpio device-attribute leak

The gpio device attributes were never destroyed when the gpio was
unexported (or on export failures).

Use device_create_with_groups() to create the default device attributes
of the gpio class device. Note that this also fixes the
attribute-creation race with userspace for these attributes.

Remove contingent attributes in export error path and on unexport.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Cc: stable <stable@vger.kernel.org> # v2.6.27+
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-sysfs.c