From patchwork Fri Mar 28 17:57:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 27371 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 827AB20062 for ; Fri, 28 Mar 2014 17:58:02 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf11940857veb.0 for ; Fri, 28 Mar 2014 10:58:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:thread-index:dlp-filter:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding:content-language; bh=nvxQOhmHukdwdqO4wH8YVl+s+/5i9t8BKlSaaIyLlfo=; b=f2Bi20mwG/CFKpv26WvSN4VKbqU420+4DbMbTyHYxH818Mf+fTTysaaNQkl040jzRh Tz4o2cxmqhgNwaV+jnzmPbIIJUPGtAEw14JTwqEvc8xSfOXcqVty0ZH4DMLYL9XlNx35 0OD2L6j60B2yHLd2zfCXVnpKmmd2JER5Jshk28kvuKVkYyqmh5Z5ijdcj27+qxzAMGkG y6fnOhXyfIHhAwovveJWPP3SsfOROFZUs4zVCIj3p7iCcbkYsweMMrj+NEPUVfKRJhr5 wlVio+z7zQzEnscMXJuXBjRhDIjzo4DP7+r2VtSdotdlGjDtB8ufzxrd/KQoHEUhRV1G muDA== X-Gm-Message-State: ALoCoQn4SGVMCF/FWnSxi6ifQRMmvaLPIYQfL2lTV4LVWjuE0jLrZzbnnmiKl61DDGoFFNWLaCOA X-Received: by 10.58.85.3 with SMTP id d3mr964817vez.40.1396029482277; Fri, 28 Mar 2014 10:58:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.37 with SMTP id e34ls1545841qge.4.gmail; Fri, 28 Mar 2014 10:58:01 -0700 (PDT) X-Received: by 10.220.106.84 with SMTP id w20mr8354311vco.18.1396029481860; Fri, 28 Mar 2014 10:58:01 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id k2si1384246vcj.30.2014.03.28.10.58.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 10:58:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so6368097vcb.9 for ; Fri, 28 Mar 2014 10:58:01 -0700 (PDT) X-Received: by 10.220.88.204 with SMTP id b12mr8202967vcm.3.1396029481773; Fri, 28 Mar 2014 10:58:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp28147vcv; Fri, 28 Mar 2014 10:58:01 -0700 (PDT) X-Received: by 10.66.233.169 with SMTP id tx9mr9942470pac.7.1396029480997; Fri, 28 Mar 2014 10:58:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zw7si4106653pac.316.2014.03.28.10.58.00; Fri, 28 Mar 2014 10:58:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754043AbaC1R54 (ORCPT + 9 others); Fri, 28 Mar 2014 13:57:56 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:48670 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754023AbaC1R5w (ORCPT ); Fri, 28 Mar 2014 13:57:52 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N35000Z9R8FEP40@mailout3.samsung.com>; Sat, 29 Mar 2014 02:57:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.51]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 7E.05.09028.F18B5335; Sat, 29 Mar 2014 02:57:51 +0900 (KST) X-AuditID: cbfee68e-b7f566d000002344-0e-5335b81f267f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 0D.56.29263.F18B5335; Sat, 29 Mar 2014 02:57:51 +0900 (KST) Received: from VISITOR1LAB ([105.128.34.229]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N3500HZER8CVH20@mmp2.samsung.com>; Sat, 29 Mar 2014 02:57:51 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: 'David Miller' , 'kbuild test robot' , 'Girish K S' , 'Siva Reddy' , 'Vipul Pandya' Subject: [PATCH net-next] net: sxgbe: fix potential null dereference Date: Fri, 28 Mar 2014 10:57:44 -0700 Message-id: <031c01cf4aaf$3a4227a0$aec676e0$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9KrxZy/HbAz3ITQ9SynT1m3IsDIw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsVy+t8zY135HabBBqs/CFvMOd/CYvH++Xpm i/lHdzBZzDi/j8ni2AIxixVNWxktti24wOzA7rFl5U0mj8V7XjJ59G1ZxejxeZNcA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hAReJ18cPMHUxcnCwCKhKzO8rAwnzClhKtH8+zQRhC0r8mHyPBaJV S2L9zuNMELa8xOY1b5khDlKQ2HH2NSPEKj2J2Qf6mSFqxCUmPXjIPoFRYBaSUbOQjJqFZNQs JC0LGFlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgRH+DOpHYwrGywOMQpwMCrx8Aq0mgYL sSaWFVfmHmKU4GBWEuHNmggU4k1JrKxKLcqPLyrNSS0+xJgM9OhEZinR5Hxg8skriTc0NjEz sjQyszAyMTcnTVhJnPdAq3WgkEB6YklqdmpqQWoRzBYmDk6pBsb0r+l3egteuExaILBnRtca 9m0BV24+YTlW95Rju7/bpOSCmy5h+WtWv336+tODg7GpAVcsljxWcEt20xQLP/967bs2DY+P T9+JiE3XaZjAPOOR9970oGPv/jR7vhd/9MGr7tZX9cWmC2WiSxZweimrcpx95xCZsCnVeG7C 1atsiQ4dLfL3hU2UWIozEg21mIuKEwHc0u6wNAMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bh74.an@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Content-language: en-us From: Byungho An This fixes following: drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c:1828 sxgbe_hw_init() error: potential null dereference 'priv->hw'. (kmalloc returns null) Reported-by: kbuild test robot Signed-off-by: Byungho An --- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c index ee1fd3c..a72688e 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c @@ -2039,11 +2039,13 @@ static void sxgbe_get_ops(struct sxgbe_ops * const ops_ptr) * Description: this function checks the HW capability * (if supported) and sets the driver's features. */ -static void sxgbe_hw_init(struct sxgbe_priv_data * const priv) +static int sxgbe_hw_init(struct sxgbe_priv_data * const priv) { u32 ctrl_ids; priv->hw = kmalloc(sizeof(*priv->hw), GFP_KERNEL); + if(!priv->hw) + return -ENOMEM; /* get the hardware ops */ sxgbe_get_ops(priv->hw); @@ -2064,6 +2066,8 @@ static void sxgbe_hw_init(struct sxgbe_priv_data * const priv) if (priv->hw_cap.rx_csum_offload) pr_info("RX Checksum offload supported\n"); + + return 0; } /** @@ -2102,7 +2106,9 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device, sxgbe_verify_args(); /* Init MAC and get the capabilities */ - sxgbe_hw_init(priv); + ret = sxgbe_hw_init(priv); + if (ret) + goto error_free_netdev; /* allocate memory resources for Descriptor rings */ ret = txring_mem_alloc(priv);