* [PATCH] input: handle sysfs errors
@ 2006-10-10 6:49 Jeff Garzik
2006-10-10 13:58 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2006-10-10 6:49 UTC (permalink / raw)
To: dmitry.torokhov, Andrew Morton, LKML
Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
drivers/input/keyboard/atkbd.c | 25 ++++++++++++++++++++-----
drivers/input/mouse/psmouse-base.c | 11 +++++++++--
drivers/input/mouse/trackpoint.c | 7 ++++++-
3 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index b6ef9ea..4d5c790 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -961,11 +961,16 @@ static int atkbd_connect(struct serio *s
atkbd_set_keycode_table(atkbd);
atkbd_set_device_attrs(atkbd);
- device_create_file(&serio->dev, &atkbd_attr_extra);
- device_create_file(&serio->dev, &atkbd_attr_scroll);
- device_create_file(&serio->dev, &atkbd_attr_set);
- device_create_file(&serio->dev, &atkbd_attr_softrepeat);
- device_create_file(&serio->dev, &atkbd_attr_softraw);
+ err = device_create_file(&serio->dev, &atkbd_attr_extra);
+ if (err) goto fail_serio;
+ err = device_create_file(&serio->dev, &atkbd_attr_scroll);
+ if (err) goto fail_extra;
+ err = device_create_file(&serio->dev, &atkbd_attr_set);
+ if (err) goto fail_scroll;
+ err = device_create_file(&serio->dev, &atkbd_attr_softrepeat);
+ if (err) goto fail_set;
+ err = device_create_file(&serio->dev, &atkbd_attr_softraw);
+ if (err) goto fail_softrep;
atkbd_enable(atkbd);
@@ -973,6 +978,16 @@ static int atkbd_connect(struct serio *s
return 0;
+ fail_softrep:
+ device_remove_file(&serio->dev, &atkbd_attr_softrepeat);
+ fail_set:
+ device_remove_file(&serio->dev, &atkbd_attr_set);
+ fail_scroll:
+ device_remove_file(&serio->dev, &atkbd_attr_scroll);
+ fail_extra:
+ device_remove_file(&serio->dev, &atkbd_attr_extra);
+ fail_serio:
+ serio_close(serio);
fail: serio_set_drvdata(serio, NULL);
input_free_device(dev);
kfree(atkbd);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 6f9b2c7..0bd349f 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1152,11 +1152,13 @@ static int psmouse_connect(struct serio
input_register_device(psmouse->dev);
+ retval = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
+ if (retval)
+ goto err_out;
+
if (parent && parent->pt_activate)
parent->pt_activate(parent);
- sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
-
psmouse_activate(psmouse);
retval = 0;
@@ -1174,6 +1176,11 @@ out:
mutex_unlock(&psmouse_mutex);
return retval;
+err_out:
+ input_unregister_device(psmouse->dev);
+ psmouse_set_state(psmouse, PSMOUSE_IGNORE);
+ serio_close(serio);
+ goto out;
}
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index ae5871a..8d639ff 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -293,6 +293,7 @@ int trackpoint_detect(struct psmouse *ps
struct ps2dev *ps2dev = &psmouse->ps2dev;
unsigned char firmware_id;
unsigned char button_info;
+ int rc;
if (trackpoint_start_protocol(psmouse, &firmware_id))
return -1;
@@ -318,7 +319,11 @@ int trackpoint_detect(struct psmouse *ps
trackpoint_defaults(priv);
trackpoint_sync(psmouse);
- sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
+ rc=sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
+ if (rc) {
+ kfree(priv);
+ return -1;
+ }
printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] input: handle sysfs errors
2006-10-10 6:49 [PATCH] input: handle sysfs errors Jeff Garzik
@ 2006-10-10 13:58 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2006-10-10 13:58 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrew Morton, LKML
On 10/10/06, Jeff Garzik <jeff@garzik.org> wrote:
>
> - device_create_file(&serio->dev, &atkbd_attr_extra);
> - device_create_file(&serio->dev, &atkbd_attr_scroll);
> - device_create_file(&serio->dev, &atkbd_attr_set);
> - device_create_file(&serio->dev, &atkbd_attr_softrepeat);
> - device_create_file(&serio->dev, &atkbd_attr_softraw);
> + err = device_create_file(&serio->dev, &atkbd_attr_extra);
> + if (err) goto fail_serio;
I have a patch that converts atkbd to attribute group and also one
that handles errors from input_register_drevice. I will add sysfs
error checks there as well.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] input: handle sysfs errors
@ 2006-10-10 13:37 Jeff Garzik
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2006-10-10 13:37 UTC (permalink / raw)
To: dmitry.torokhov, Andrew Morton, LKML
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)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-10 13:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-10 6:49 [PATCH] input: handle sysfs errors Jeff Garzik
2006-10-10 13:58 ` Dmitry Torokhov
2006-10-10 13:37 Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).