aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-12 01:06:53 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-10-12 01:06:53 -0400
commitb435fdcda126db42343b8055d04a0a27c229717b (patch)
treeb35685bd142ae8fb6e92f6a6468bf3f6676b75d0 /drivers/input
parent23de1510e2468ea349354889097e018d4e8770c5 (diff)
Input: fm801-gp - handle errors from pci_enable_device()
Signed-off-by: Jeff Garzik <jeff@garzik.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/gameport/fm801-gp.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 90de5afe03c2..1dec00e20dbc 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -82,17 +82,19 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
82{ 82{
83 struct fm801_gp *gp; 83 struct fm801_gp *gp;
84 struct gameport *port; 84 struct gameport *port;
85 int error;
85 86
86 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); 87 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
87 port = gameport_allocate_port(); 88 port = gameport_allocate_port();
88 if (!gp || !port) { 89 if (!gp || !port) {
89 printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); 90 printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
90 kfree(gp); 91 error = -ENOMEM;
91 gameport_free_port(port); 92 goto err_out_free;
92 return -ENOMEM;
93 } 93 }
94 94
95 pci_enable_device(pci); 95 error = pci_enable_device(pci);
96 if (error)
97 goto err_out_free;
96 98
97 port->open = fm801_gp_open; 99 port->open = fm801_gp_open;
98#ifdef HAVE_COOKED 100#ifdef HAVE_COOKED
@@ -108,9 +110,8 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
108 if (!gp->res_port) { 110 if (!gp->res_port) {
109 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", 111 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
110 port->io, port->io + 0x0f); 112 port->io, port->io + 0x0f);
111 gameport_free_port(port); 113 error = -EBUSY;
112 kfree(gp); 114 goto err_out_disable_dev;
113 return -EBUSY;
114 } 115 }
115 116
116 pci_set_drvdata(pci, gp); 117 pci_set_drvdata(pci, gp);
@@ -119,6 +120,13 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
119 gameport_register_port(port); 120 gameport_register_port(port);
120 121
121 return 0; 122 return 0;
123
124 err_out_disable_dev:
125 pci_disable_device(pci);
126 err_out_free:
127 gameport_free_port(port);
128 kfree(gp);
129 return error;
122} 130}
123 131
124static void __devexit fm801_gp_remove(struct pci_dev *pci) 132static void __devexit fm801_gp_remove(struct pci_dev *pci)