From: Jeff Garzik <jeff@garzik.org>
To: dmitry.torokhov@gmail.com, Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] input: handle sysfs errors
Date: Tue, 10 Oct 2006 09:37:11 -0400 [thread overview]
Message-ID: <20061010133710.GA10299@havoc.gtf.org> (raw)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
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)
next reply other threads:[~2006-10-10 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-10 13:37 Jeff Garzik [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-10-10 6:49 Jeff Garzik
2006-10-10 13:58 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061010133710.GA10299@havoc.gtf.org \
--to=jeff@garzik.org \
--cc=akpm@osdl.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®