Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp622399ybx; Wed, 30 Oct 2019 02:17:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeHNyiJDh9qt1E4wV4AIU4sd6hrfs5wxLJcEvF8E2nWpuqhWaR2kM5T8SHkhe8GVtjrDlP X-Received: by 2002:aa7:cd03:: with SMTP id b3mr30225886edw.95.1572427061135; Wed, 30 Oct 2019 02:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572427061; cv=none; d=google.com; s=arc-20160816; b=Hf/up/VK0FVhDpajn6+crv1kJc/7KqL1bUcE7teR73ByYNCDacNNvTBPp9E2fNfrdh YGPBHWFMeDCLV0+7m/iGvRrsupwIh+oUFhXMqsnLh9WsQOv3f0bxs4NPJgsh21KNBgcA mqYtj3EmXbP6EA8QNf06OS2hDL0znenZeT5BArUB+GCfLab7VZjAt/3Vlao8ysybrTUJ TVlCli0DAa33xj1ceceXRQKkMnf6jgGIckHaPcDsbdOBAHwgycZDGHiT63knjxRoHtWP L2lSv7XGAAB7XyMnMr5DN9Ylv9U69fRRM9R2PUdL6WomnO+YjE7y5hVm/bYiBR2XaXmE DaFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=XlMqg9QiSYobkWRHpFScQjbSCpTE5vpJOnVz+ZpahfI=; b=sCkegw+LxMxIU0vUEl62FD13t55p6jfN6058ppIVQcuYWz6uudTEbPj90meiT9ZCQR lggPTWBUISlSRCzS0vxIKgcI+m4pVVPDDPhBlaABmTtk7HFLITPCHRqLjuENRp3dz75S n9xeDxxdkBN38jKvljsS/KbdWIWgMb/ZE8eF11C2JWjH6pi4Ivabuqe5jgZIXUCuZiqA +/lo1Qa0k4SUOCZlBwrNaeWwnIGpC+44oJLuQUufgNnHbnOgV7vt5ysvI6hutan/srnm qt+S6iWrSM9FTNcoPd450qNnWNgkwWMVKlILcyy9Yd3+OXmwy9XB5kfIZkKT+lrwFogn MAcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jz12si793686ejb.193.2019.10.30.02.17.17; Wed, 30 Oct 2019 02:17:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbfJ3JQr (ORCPT + 99 others); Wed, 30 Oct 2019 05:16:47 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:52650 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726028AbfJ3JQr (ORCPT ); Wed, 30 Oct 2019 05:16:47 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C0635D07DE9A63F65658; Wed, 30 Oct 2019 17:16:44 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Wed, 30 Oct 2019 17:16:36 +0800 From: zhong jiang To: CC: , , , , Subject: [PATCH] sfc: should check the return value after allocating memory Date: Wed, 30 Oct 2019 17:12:45 +0800 Message-ID: <1572426765-43211-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kcalloc may fails to allocate memory, hence if it is in that case, We should drop out in time. Signed-off-by: zhong jiang --- drivers/net/ethernet/sfc/efx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 2fef740..712380a 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -3040,6 +3040,8 @@ static int efx_init_struct(struct efx_nic *efx, /* Failure to allocate is not fatal, but may degrade ARFS performance */ efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE, sizeof(*efx->rps_hash_table), GFP_KERNEL); + if (!efx->rps_hash_table) + goto fail; #endif efx->phy_op = &efx_dummy_phy_operations; efx->mdio.dev = net_dev; -- 1.7.12.4