gpio: sysfs: fix gpio device-attribute leak
authorJohan Hovold <johan@kernel.org>
Tue, 13 Jan 2015 12:00:05 +0000 (13:00 +0100)
committerJiri Slaby <jslaby@suse.cz>
Thu, 29 Jan 2015 14:44:54 +0000 (15:44 +0100)
commitc96807abeade37994e1105bbea59e79c3d699114
treeacb1baae4df2bee0980e7775ccd4b6ac8e4c29cc
parent0145d4dd46a3ccd2be6438439201762c7a89d0fb
gpio: sysfs: fix gpio device-attribute leak

commit 0915e6feb38de8d3601819992a5bd050201a56fa upstream.

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")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/gpio/gpiolib.c