diff mbox

wireless: ERR_PTR vs null

Message ID alpine.DEB.2.00.0907241000250.11771@bicker (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter July 25, 2009, 12:22 p.m. UTC
iwm_wdev_alloc() returns an ERR_PTR on failure and not null.  It also 
prints its own dev_err() message so I removed that as well.

Compile tested only.  Sorry.  
Found by smatch (http://repo.or.cz/w/smatch.git).

regards,
dan carpenter

Signed-off-by: Dan Carpenter <error27@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Marcel Holtmann July 25, 2009, 12:46 p.m. UTC | #1
Hi Dan,

> iwm_wdev_alloc() returns an ERR_PTR on failure and not null.  It also 
> prints its own dev_err() message so I removed that as well.
> 
> Compile tested only.  Sorry.  
> Found by smatch (http://repo.or.cz/w/smatch.git).
> 
> regards,
> dan carpenter
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> --- orig/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:56:49.000000000 +0300
> +++ devel/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:57:31.000000000 +0300
> @@ -106,10 +106,8 @@
>  	int ret = 0;
>  
>  	wdev = iwm_wdev_alloc(sizeof_bus, dev);
> -	if (!wdev) {
> -		dev_err(dev, "no memory for wireless device instance\n");
> -		return ERR_PTR(-ENOMEM);
> -	}
> +	if (IS_ERR(wdev))
> +		return wdev;
>  
>  	iwm = wdev_to_iwm(wdev);
>  	iwm->bus_ops = if_ops;

I just quickly double-checked with the code. Patch looks good.

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhu Yi July 27, 2009, 1:26 a.m. UTC | #2
On Sat, 2009-07-25 at 20:22 +0800, Dan Carpenter wrote:
> iwm_wdev_alloc() returns an ERR_PTR on failure and not null.  It also 
> prints its own dev_err() message so I removed that as well.
> 
> Compile tested only.  Sorry.  
> Found by smatch (http://repo.or.cz/w/smatch.git).
> 
> regards,
> dan carpenter
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Zhu Yi <yi.zhu@intel.com>

Thanks,
-yi

> --- orig/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:56:49.000000000 +0300
> +++ devel/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:57:31.000000000 +0300
> @@ -106,10 +106,8 @@
>  	int ret = 0;
>  
>  	wdev = iwm_wdev_alloc(sizeof_bus, dev);
> -	if (!wdev) {
> -		dev_err(dev, "no memory for wireless device instance\n");
> -		return ERR_PTR(-ENOMEM);
> -	}
> +	if (IS_ERR(wdev))
> +		return wdev;
>  
>  	iwm = wdev_to_iwm(wdev);
>  	iwm->bus_ops = if_ops;

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- orig/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:56:49.000000000 +0300
+++ devel/drivers/net/wireless/iwmc3200wifi/netdev.c	2009-07-24 09:57:31.000000000 +0300
@@ -106,10 +106,8 @@ 
 	int ret = 0;
 
 	wdev = iwm_wdev_alloc(sizeof_bus, dev);
-	if (!wdev) {
-		dev_err(dev, "no memory for wireless device instance\n");
-		return ERR_PTR(-ENOMEM);
-	}
+	if (IS_ERR(wdev))
+		return wdev;
 
 	iwm = wdev_to_iwm(wdev);
 	iwm->bus_ops = if_ops;