diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:19 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:19 -0500 |
commit | 721556150e397f606a3f029736d77a27503f94e2 (patch) | |
tree | 1bdce32c4d1421f0dfbd9871986fcb7eaa6aba56 /drivers/input/mouse/pc110pad.c | |
parent | 127278ce2254c61f1346500374d61e33f74a8729 (diff) |
Input: mice - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse/pc110pad.c')
-rw-r--r-- | drivers/input/mouse/pc110pad.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index 8c075aa7223b..f155c1fea04e 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c | |||
@@ -108,6 +108,7 @@ static int pc110pad_open(struct input_dev *dev) | |||
108 | static int __init pc110pad_init(void) | 108 | static int __init pc110pad_init(void) |
109 | { | 109 | { |
110 | struct pci_dev *dev; | 110 | struct pci_dev *dev; |
111 | int err; | ||
111 | 112 | ||
112 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); | 113 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); |
113 | if (dev) { | 114 | if (dev) { |
@@ -124,16 +125,16 @@ static int __init pc110pad_init(void) | |||
124 | outb(PC110PAD_OFF, pc110pad_io + 2); | 125 | outb(PC110PAD_OFF, pc110pad_io + 2); |
125 | 126 | ||
126 | if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) { | 127 | if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) { |
127 | release_region(pc110pad_io, 4); | ||
128 | printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); | 128 | printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); |
129 | return -EBUSY; | 129 | err = -EBUSY; |
130 | goto err_release_region; | ||
130 | } | 131 | } |
131 | 132 | ||
132 | if (!(pc110pad_dev = input_allocate_device())) { | 133 | pc110pad_dev = input_allocate_device(); |
133 | free_irq(pc110pad_irq, NULL); | 134 | if (!pc110pad_dev) { |
134 | release_region(pc110pad_io, 4); | ||
135 | printk(KERN_ERR "pc110pad: Not enough memory.\n"); | 135 | printk(KERN_ERR "pc110pad: Not enough memory.\n"); |
136 | return -ENOMEM; | 136 | err = -ENOMEM; |
137 | goto err_free_irq; | ||
137 | } | 138 | } |
138 | 139 | ||
139 | pc110pad_dev->name = "IBM PC110 TouchPad"; | 140 | pc110pad_dev->name = "IBM PC110 TouchPad"; |
@@ -153,9 +154,20 @@ static int __init pc110pad_init(void) | |||
153 | pc110pad_dev->open = pc110pad_open; | 154 | pc110pad_dev->open = pc110pad_open; |
154 | pc110pad_dev->close = pc110pad_close; | 155 | pc110pad_dev->close = pc110pad_close; |
155 | 156 | ||
156 | input_register_device(pc110pad_dev); | 157 | err = input_register_device(pc110pad_dev); |
158 | if (err) | ||
159 | goto err_free_dev; | ||
157 | 160 | ||
158 | return 0; | 161 | return 0; |
162 | |||
163 | err_free_dev: | ||
164 | input_free_device(pc110pad_dev); | ||
165 | err_free_irq: | ||
166 | free_irq(pc110pad_irq, NULL); | ||
167 | err_release_region: | ||
168 | release_region(pc110pad_io, 4); | ||
169 | |||
170 | return err; | ||
159 | } | 171 | } |
160 | 172 | ||
161 | static void __exit pc110pad_exit(void) | 173 | static void __exit pc110pad_exit(void) |