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 02:49:39 -0400 [thread overview]
Message-ID: <20061010064939.GA21385@havoc.gtf.org> (raw)
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);
next reply other threads:[~2006-10-10 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-10 6:49 Jeff Garzik [this message]
2006-10-10 13:58 ` Dmitry Torokhov
2006-10-10 13:37 Jeff Garzik
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=20061010064939.GA21385@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®