From patchwork Mon Jan 10 02:26:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 78065 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C0F8AB6F2B for ; Mon, 10 Jan 2011 13:24:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753351Ab1AJCXs (ORCPT ); Sun, 9 Jan 2011 21:23:48 -0500 Received: from mail-gw0-f46.google.com ([74.125.83.46]:63352 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865Ab1AJCXq (ORCPT ); Sun, 9 Jan 2011 21:23:46 -0500 Received: by gwj20 with SMTP id 20so8368390gwj.19 for ; Sun, 09 Jan 2011 18:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=NLWdgfED6bIl98ki9itlaZxNOgDF2KatMPeLxRhFL+o=; b=qAy/qkR0GLiAxO9GZ8p9KiODxQqx041LtmSyWpjImH98q8nAILNcv4N9JYGXTbixAC 3fvkHWpY6tz0MdpwdUu3IcZdHA9+2oTh1k72kjwcXQGWQKt5nkPgh46S9KfQRsIF3DGE jQY64YdaU2EruDlhHOGt+onPr6yAHzznHLr1Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=RVjqPBtso8fNLlryhI+25wCGRp+s7O1zqhh/KtQQrcCT2Ct64VZFDPl29KZwKIt93h e6xyAxGJCl6pKg1tpIvAcxi3ET512WFOu8Cce6e+0ck8PO4Kw4Bt3HB+ssAO10uWd099 yQ43NXAbFFR7l9XQZ/c87QPOGferpBtJ2HrL0= Received: by 10.150.200.18 with SMTP id x18mr27218128ybf.142.1294626225412; Sun, 09 Jan 2011 18:23:45 -0800 (PST) Received: from [192.168.100.50] (60-251-136-127.HINET-IP.hinet.net [60.251.136.127]) by mx.google.com with ESMTPS id u31sm14401140yba.21.2011.01.09.18.23.40 (version=SSLv3 cipher=RC4-MD5); Sun, 09 Jan 2011 18:23:44 -0800 (PST) Subject: [PATCH] iwmc3200wifi: Return proper error for iwm_if_alloc From: Axel Lin To: linux-kernel@vger.kernel.org Cc: Samuel Ortiz , Intel Linux Wireless , Zhu Yi , "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Date: Mon, 10 Jan 2011 10:26:00 +0800 Message-Id: <1294626360.25455.1.camel@mola> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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; }