public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 06/14] staging: rtl8192u: improve error path
@ 2010-09-05 18:32 Kulikov Vasiliy
  2010-09-06 10:11 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Kulikov Vasiliy @ 2010-09-05 18:32 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Vasiliy Kulikov, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	Julia Lawall, Ben Hutchings, Mike Gilks, devel, linux-kernel

From: Vasiliy Kulikov <segooon@gmail.com>

Functions alloc_ieee80211 and register_netdev may fail. Check for it.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 I couldn't compile this driver at all, so it is not tested.

 drivers/staging/rtl8192u/r8192U_core.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 1ff7850..b6d429c 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -5793,10 +5793,12 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
 	struct net_device *dev = NULL;
 	struct r8192_priv *priv= NULL;
 	struct usb_device *udev = interface_to_usbdev(intf);
+	int ret;
 	RT_TRACE(COMP_INIT, "Oops: i'm coming\n");
 
 	dev = alloc_ieee80211(sizeof(struct r8192_priv));
-
+	if (dev == NULL)
+		return -ENOMEM;
 
 	usb_set_intfdata(intf, dev);
 	SET_NETDEV_DEV(dev, &intf->dev);
@@ -5826,12 +5828,16 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
 	RT_TRACE(COMP_INIT, "Driver probe completed1\n");
 	if(rtl8192_init(dev)!=0){
 		RT_TRACE(COMP_ERR, "Initialization failed");
+		ret = -ENODEV;
 		goto fail;
 	}
 	netif_carrier_off(dev);
 	netif_stop_queue(dev);
 
-	register_netdev(dev);
+	ret = register_netdev(dev);
+	if (ret)
+		goto fail2;
+
 	RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name);
 	rtl8192_proc_init_one(dev);
 
@@ -5839,13 +5845,20 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
 	RT_TRACE(COMP_INIT, "Driver probe completed\n");
 	return 0;
 
-
+fail2:
+	rtl8192_down(dev);
+	if (priv->pFirmware) {
+		kfree(priv->pFirmware);
+		priv->pFirmware = NULL;
+	}
+	rtl8192_usb_deleteendpoints(dev);
+	destroy_workqueue(priv->priv_wq);
+	mdelay(10);
 fail:
 	free_ieee80211(dev);
 
 	RT_TRACE(COMP_ERR, "wlan driver load failed\n");
-	return -ENODEV;
-
+	return ret;
 }
 
 //detach all the work and timer structure declared or inititialize in r8192U_init function.
-- 
1.7.0.4


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

* Re: [PATCH 06/14] staging: rtl8192u: improve error path
  2010-09-05 18:32 [PATCH 06/14] staging: rtl8192u: improve error path Kulikov Vasiliy
@ 2010-09-06 10:11 ` Dan Carpenter
  2010-09-06 13:50   ` Kulikov Vasiliy
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-09-06 10:11 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	Julia Lawall, Ben Hutchings, Mike Gilks, devel, linux-kernel

On Sun, Sep 05, 2010 at 10:32:41PM +0400, Kulikov Vasiliy wrote:
> +fail2:
> +	rtl8192_down(dev);
> +	if (priv->pFirmware) {
> +		kfree(priv->pFirmware);
> +		priv->pFirmware = NULL;
> +	}
> +	rtl8192_usb_deleteendpoints(dev);
> +	destroy_workqueue(priv->priv_wq);
> +	mdelay(10);

What's this delay for?

regards,
dan carpenter

>  fail:
>  	free_ieee80211(dev);


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

* Re: [PATCH 06/14] staging: rtl8192u: improve error path
  2010-09-06 10:11 ` Dan Carpenter
@ 2010-09-06 13:50   ` Kulikov Vasiliy
  2010-09-06 18:02     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Kulikov Vasiliy @ 2010-09-06 13:50 UTC (permalink / raw)
  To: Dan Carpenter, kernel-janitors, Greg Kroah-Hartman,
	Mauro Carvalho Chehab, Julia Lawall, Ben Hutchings, Mike Gilks,
	devel, linux-kernel

On Mon, Sep 06, 2010 at 12:11 +0200, Dan Carpenter wrote:
> On Sun, Sep 05, 2010 at 10:32:41PM +0400, Kulikov Vasiliy wrote:
> > +fail2:
> > +	rtl8192_down(dev);
> > +	if (priv->pFirmware) {
> > +		kfree(priv->pFirmware);
> > +		priv->pFirmware = NULL;
> > +	}
> > +	rtl8192_usb_deleteendpoints(dev);
> > +	destroy_workqueue(priv->priv_wq);
> > +	mdelay(10);
> 
> What's this delay for?

It was copied from rtl8192_usb_disconnect(), I don't know why it has
mdelay(10). But it's better to keep the old deallocation code, it should
have the same problems (if original code has any).

-- 
Vasiliy

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

* Re: [PATCH 06/14] staging: rtl8192u: improve error path
  2010-09-06 13:50   ` Kulikov Vasiliy
@ 2010-09-06 18:02     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2010-09-06 18:02 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	Julia Lawall, Ben Hutchings, Mike Gilks, devel, linux-kernel

On Mon, Sep 06, 2010 at 05:50:56PM +0400, Kulikov Vasiliy wrote:
> On Mon, Sep 06, 2010 at 12:11 +0200, Dan Carpenter wrote:
> > On Sun, Sep 05, 2010 at 10:32:41PM +0400, Kulikov Vasiliy wrote:
> > > +fail2:
> > > +	rtl8192_down(dev);
> > > +	if (priv->pFirmware) {
> > > +		kfree(priv->pFirmware);
> > > +		priv->pFirmware = NULL;
> > > +	}
> > > +	rtl8192_usb_deleteendpoints(dev);
> > > +	destroy_workqueue(priv->priv_wq);
> > > +	mdelay(10);
> > 
> > What's this delay for?
> 
> It was copied from rtl8192_usb_disconnect(), I don't know why it has
> mdelay(10). But it's better to keep the old deallocation code, it should
> have the same problems (if original code has any).
> 

I think the delay in rtl8192_usb_disconnect() is because we reset the
device.  (Of course, in that case, it would have been better to move the
delay into rtl8192_reset().  And also the reset code has been commented
out.)

In this case here, the delay is serves no purpose and should be removed.

regards,
dan carpenter

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

end of thread, other threads:[~2010-09-06 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 18:32 [PATCH 06/14] staging: rtl8192u: improve error path Kulikov Vasiliy
2010-09-06 10:11 ` Dan Carpenter
2010-09-06 13:50   ` Kulikov Vasiliy
2010-09-06 18:02     ` Dan Carpenter

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