Commit b435fdcd authored by Jeff Garzik's avatar Jeff Garzik Committed by Dmitry Torokhov

Input: fm801-gp - handle errors from pci_enable_device()

Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 23de1510
...@@ -82,17 +82,19 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device ...@@ -82,17 +82,19 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
{ {
struct fm801_gp *gp; struct fm801_gp *gp;
struct gameport *port; struct gameport *port;
int error;
gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
port = gameport_allocate_port(); port = gameport_allocate_port();
if (!gp || !port) { if (!gp || !port) {
printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
kfree(gp); error = -ENOMEM;
gameport_free_port(port); goto err_out_free;
return -ENOMEM;
} }
pci_enable_device(pci); error = pci_enable_device(pci);
if (error)
goto err_out_free;
port->open = fm801_gp_open; port->open = fm801_gp_open;
#ifdef HAVE_COOKED #ifdef HAVE_COOKED
...@@ -108,9 +110,8 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device ...@@ -108,9 +110,8 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
if (!gp->res_port) { if (!gp->res_port) {
printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
port->io, port->io + 0x0f); port->io, port->io + 0x0f);
gameport_free_port(port); error = -EBUSY;
kfree(gp); goto err_out_disable_dev;
return -EBUSY;
} }
pci_set_drvdata(pci, gp); pci_set_drvdata(pci, gp);
...@@ -119,6 +120,13 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device ...@@ -119,6 +120,13 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
gameport_register_port(port); gameport_register_port(port);
return 0; return 0;
err_out_disable_dev:
pci_disable_device(pci);
err_out_free:
gameport_free_port(port);
kfree(gp);
return error;
} }
static void __devexit fm801_gp_remove(struct pci_dev *pci) static void __devexit fm801_gp_remove(struct pci_dev *pci)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment