Signed-off-by: Jeff Garzik <[email protected]>
---
drivers/input/evdev.c | 14 +++++++++++---
drivers/input/joydev.c | 13 ++++++++++---
drivers/input/mousedev.c | 16 +++++++++++++---
drivers/input/tsdev.c | 14 +++++++++++---
4 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 6439f37..f35051b 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -621,7 +621,7 @@ static struct input_handle *evdev_connec
{
struct evdev *evdev;
struct class_device *cdev;
- int minor;
+ int minor, rc;
for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
if (minor == EVDEV_MINORS) {
@@ -650,10 +650,18 @@ static struct input_handle *evdev_connec
dev->cdev.dev, evdev->name);
/* temporary symlink to keep userspace happy */
- sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
- evdev->name);
+ rc = sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
+ evdev->name);
+ if (rc)
+ goto err_out;
return &evdev->handle;
+
+err_out:
+ class_device_destroy(&input_class,
+ MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
+ evdev_free(evdev);
+ return NULL;
}
static void evdev_disconnect(struct input_handle *handle)
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 9f3529a..5260632 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -470,7 +470,7 @@ static struct input_handle *joydev_conne
{
struct joydev *joydev;
struct class_device *cdev;
- int i, j, t, minor;
+ int i, j, t, minor, rc;
for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
if (minor == JOYDEV_MINORS) {
@@ -539,10 +539,17 @@ static struct input_handle *joydev_conne
dev->cdev.dev, joydev->name);
/* temporary symlink to keep userspace happy */
- sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
- joydev->name);
+ rc = sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
+ joydev->name);
+ if (rc)
+ goto err_out;
return &joydev->handle;
+
+err_out:
+ class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
+ joydev_free(joydev);
+ return NULL;
}
static void joydev_disconnect(struct input_handle *handle)
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index a22a74a..77e8596 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -629,7 +629,7 @@ static struct input_handle *mousedev_con
{
struct mousedev *mousedev;
struct class_device *cdev;
- int minor = 0;
+ int minor = 0, rc;
for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++);
if (minor == MOUSEDEV_MINORS) {
@@ -661,10 +661,20 @@ static struct input_handle *mousedev_con
dev->cdev.dev, mousedev->name);
/* temporary symlink to keep userspace happy */
- sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
- mousedev->name);
+ rc = sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
+ mousedev->name);
+ if (rc)
+ goto err_out;
return &mousedev->handle;
+
+err_out:
+ class_device_destroy(&input_class,
+ MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
+ if (mousedev_mix.open)
+ input_close_device(&mousedev->handle);
+ mousedev_free(mousedev);
+ return NULL;
}
static void mousedev_disconnect(struct input_handle *handle)
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index a730c46..49e34ce 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -372,7 +372,7 @@ static struct input_handle *tsdev_connec
{
struct tsdev *tsdev;
struct class_device *cdev;
- int minor, delta;
+ int minor, delta, rc;
for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++);
if (minor >= TSDEV_MINORS / 2) {
@@ -416,10 +416,18 @@ static struct input_handle *tsdev_connec
dev->cdev.dev, tsdev->name);
/* temporary symlink to keep userspace happy */
- sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
- tsdev->name);
+ rc = sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
+ tsdev->name);
+ if (rc)
+ goto err_out;
return &tsdev->handle;
+
+err_out:
+ class_device_destroy(&input_class,
+ MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
+ tsdev_free(tsdev);
+ return NULL;
}
static void tsdev_disconnect(struct input_handle *handle)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]