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: 3906161 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 893EE9F2E8 for ; Fri, 28 Mar 2014 17:58:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A70820272 for ; Fri, 28 Mar 2014 17:57:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 508D52028D for ; Fri, 28 Mar 2014 17:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754043AbaC1R54 (ORCPT ); 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 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9KrxZy/HbAz3ITQ9SynT1m3IsDIw== Content-language: en-us X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsVy+t8zY135HabBBqs/CFvMOd/CYvH++Xpm i/lHdzBZzDi/j8ni2AIxixVNWxktti24wOzA7rFl5U0mj8V7XjJ59G1ZxejxeZNcAEsUl01K ak5mWWqRvl0CV8b8O5dZCp7yVpxacJ69gfEwdxcjJ4eEgIlEz+39TBC2mMSFe+vZuhi5OIQE ljFKvNh6jg2m6MSN51CJ6YwSf2f/ZIZw/jJKLJrYCFbFJqAm0TzzMpgtImArseTIZ3YQm1ng MqNE20pXEFtYwEXi9fEDQOs4OFgEVCXm95WBhHkFLCXaP59mgrAFJX5MvscC0aolsX7ncSYI W15i85q3zBAHKUjsOPuaEWKVnsTsA/3MEDXiEpMePGQHuU1C4Bi7RMPsy2A3sAgISHybfIgF ZK+EgKzEpgNQcyQlDq64wTKBUWwWktWzkKyehWT1LCQrFjCyrGIUTS1ILihOSi8y0itOzC0u zUvXS87P3cQIicG+HYw3D1gfYkwGWj+RWUo0OR8Yw3kl8YbGZkYWpiamxkbmlmak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/jR7vhd/9MGr7tZX9cWmC2WiSxZweimrcpx95xCZsCnVeG7C 1atsiQ4dLfL3hU2UWIozEg21mIuKEwHc0u6wNAMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);