All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iwmc3200wifi: Return proper error for iwm_if_alloc
@ 2011-01-10  2:26 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2011-01-10  2:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Samuel Ortiz, Intel Linux Wireless, Zhu Yi, John W. Linville,
	linux-wireless, netdev

In the case of alloc_netdev_mq failure and kmalloc failure,
current implementation returns ERR_PTR(0).

As a result, the caller of iwm_if_alloc does not catch the error by IS_ERR
macro. Fix it by setting proper error code for ret variable in the failure
cases.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/net/wireless/iwmc3200wifi/netdev.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index 13a69eb..5091d77 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -126,6 +126,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
 	ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, IWM_TX_QUEUES);
 	if (!ndev) {
 		dev_err(dev, "no memory for network device instance\n");
+		ret = -ENOMEM;
 		goto out_priv;
 	}
 
@@ -138,6 +139,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
 				    GFP_KERNEL);
 	if (!iwm->umac_profile) {
 		dev_err(dev, "Couldn't alloc memory for profile\n");
+		ret = -ENOMEM;
 		goto out_profile;
 	}
 
-- 
1.7.2




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-10  2:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-10  2:26 [PATCH] iwmc3200wifi: Return proper error for iwm_if_alloc Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.