aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/joydev.c
diff options
context:
space:
mode:
authorDmitry Torokhov2007-04-12 01:30:15 -0400
committerDmitry Torokhov2007-04-12 01:30:15 -0400
commitd542ed82fdc72cf63549deec19e86ee4addf2499 (patch)
tree201c713b24a429d34272998ae3ecca87c937709a /drivers/input/joydev.c
parentd0ffb9be866519775da19c0a6790f5431c1a8dc6 (diff)
Input: handlers - handle errors from input_open_device()
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joydev.c')
-rw-r--r--drivers/input/joydev.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 09b8223de5ec..4f37224d2268 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -170,6 +170,7 @@ static int joydev_open(struct inode *inode, struct file *file)
struct joydev_client *client;
struct joydev *joydev;
int i = iminor(inode) - JOYDEV_MINOR_BASE;
+ int error;
if (i >= JOYDEV_MINORS)
return -ENODEV;
@@ -185,8 +186,14 @@ static int joydev_open(struct inode *inode, struct file *file)
client->joydev = joydev;
list_add_tail(&client->node, &joydev->client_list);
- if (!joydev->open++ && joydev->exist)
- input_open_device(&joydev->handle);
+ if (!joydev->open++ && joydev->exist) {
+ error = input_open_device(&joydev->handle);
+ if (error) {
+ list_del(&client->node);
+ kfree(client);
+ return error;
+ }
+ }
file->private_data = client;
return 0;