Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jeff Garzik and committed by
Dmitry Torokhov
b435fdcd 23de1510

+15 -7
+15 -7
drivers/input/gameport/fm801-gp.c
··· 82 82 { 83 83 struct fm801_gp *gp; 84 84 struct gameport *port; 85 + int error; 85 86 86 87 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); 87 88 port = gameport_allocate_port(); 88 89 if (!gp || !port) { 89 90 printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); 90 - kfree(gp); 91 - gameport_free_port(port); 92 - return -ENOMEM; 91 + error = -ENOMEM; 92 + goto err_out_free; 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 99 port->open = fm801_gp_open; 98 100 #ifdef HAVE_COOKED ··· 110 108 if (!gp->res_port) { 111 109 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", 112 110 port->io, port->io + 0x0f); 113 - gameport_free_port(port); 114 - kfree(gp); 115 - return -EBUSY; 111 + error = -EBUSY; 112 + goto err_out_disable_dev; 116 113 } 117 114 118 115 pci_set_drvdata(pci, gp); ··· 120 119 gameport_register_port(port); 121 120 122 121 return 0; 122 + 123 + err_out_disable_dev: 124 + pci_disable_device(pci); 125 + err_out_free: 126 + gameport_free_port(port); 127 + kfree(gp); 128 + return error; 123 129 } 124 130 125 131 static void __devexit fm801_gp_remove(struct pci_dev *pci)