public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device()
@ 2006-10-12 23:27 Jiri Kosina
  2006-10-13  2:36 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Kosina @ 2006-10-12 23:27 UTC (permalink / raw)
  To: Dmitry Torokhov, Andrew Morton; +Cc: linux-kernel, linux-input

[PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device()

Fix fm801_gp_probe() not handling pci_enable_device() return value 
correctly.

Signed-off-by: Jiri Kosina <jikos@jikos.cz>

--- 

 drivers/input/gameport/fm801-gp.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 90de5af..5ac9e15 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -82,17 +82,22 @@ static int __devinit fm801_gp_probe(stru
 {
 	struct fm801_gp *gp;
 	struct gameport *port;
+	int err;
 
 	gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
 	port = gameport_allocate_port();
 	if (!gp || !port) {
 		printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
-		kfree(gp);
-		gameport_free_port(port);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto out_err;
 	}
 
-	pci_enable_device(pci);
+	err = pci_enable_device(pci);
+	if (err) {
+		printk(KERN_ERR "fm801: Cannot enable PCI device\n");
+		goto out_err;
+		
+	}
 
 	port->open = fm801_gp_open;
 #ifdef HAVE_COOKED
@@ -108,9 +113,8 @@ #endif
 	if (!gp->res_port) {
 		printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
 			port->io, port->io + 0x0f);
-		gameport_free_port(port);
-		kfree(gp);
-		return -EBUSY;
+		err = -EBUSY;
+		goto out_err;
 	}
 
 	pci_set_drvdata(pci, gp);
@@ -119,6 +123,11 @@ #endif
 	gameport_register_port(port);
 
 	return 0;
+out_err:
+	gameport_free_port(port);
+	kfree(gp);
+
+	return err;
 }
 
 static void __devexit fm801_gp_remove(struct pci_dev *pci)

-- 
Jiri Kosina

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device()
  2006-10-12 23:27 [PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device() Jiri Kosina
@ 2006-10-13  2:36 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2006-10-13  2:36 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Andrew Morton, linux-kernel, linux-input

On Thursday 12 October 2006 19:27, Jiri Kosina wrote:
> [PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device()
> 
> Fix fm801_gp_probe() not handling pci_enable_device() return value 
> correctly.
> 
> Signed-off-by: Jiri Kosina <jikos@jikos.cz>
> 
> --- 
> 
>  drivers/input/gameport/fm801-gp.c |   23 ++++++++++++++++-------
>  1 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
> index 90de5af..5ac9e15 100644
> --- a/drivers/input/gameport/fm801-gp.c
> +++ b/drivers/input/gameport/fm801-gp.c
> @@ -82,17 +82,22 @@ static int __devinit fm801_gp_probe(stru
>  {
>  	struct fm801_gp *gp;
>  	struct gameport *port;
> +	int err;
>  
>  	gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
>  	port = gameport_allocate_port();
>  	if (!gp || !port) {
>  		printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
> -		kfree(gp);
> -		gameport_free_port(port);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto out_err;
>  	}
>  

Hi Jiri,

It looks like you left pci device enabled. Anyway, Jeff Garzik beat you
to it ;) I spplied his patch to my tree yesterday.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-13  2:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-12 23:27 [PATCH] fix fm801_gp_probe() ignoring return value from pci_enable_device() Jiri Kosina
2006-10-13  2:36 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox