From b53575ecf939a4f752de87eabf1adbcfa4478a6c Mon Sep 17 00:00:00 2001 From: Christoph Fritz Date: Sun, 8 May 2011 22:50:09 +0200 Subject: mwifiex: fix null derefs, mem leaks and trivia This patch: - adds kfree() where necessary - prevents potential null dereferences - makes use of kfree_skb() - replaces -1 for failed kzallocs with -ENOMEM Signed-off-by: Christoph Fritz Reviewed-by: Kiran Divekar Tested-by: Amitkumar Karwar Acked-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless/mwifiex/main.c') diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 38f912b8fce..44957cac61e 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -69,7 +69,7 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL); if (!adapter) - return -1; + return -ENOMEM; g_adapter = adapter; adapter->card = card; @@ -516,13 +516,13 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) jiffies, priv->bss_index); if (priv->adapter->surprise_removed) { - kfree(skb); + kfree_skb(skb); priv->stats.tx_dropped++; return 0; } if (!skb->len || (skb->len > ETH_FRAME_LEN)) { dev_err(priv->adapter->dev, "Tx: bad skb len %d\n", skb->len); - kfree(skb); + kfree_skb(skb); priv->stats.tx_dropped++; return 0; } @@ -535,7 +535,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN); if (unlikely(!new_skb)) { dev_err(priv->adapter->dev, "Tx: cannot alloca new_skb\n"); - kfree(skb); + kfree_skb(skb); priv->stats.tx_dropped++; return 0; } -- cgit v1.2.3-70-g09d2