From patchwork Wed May 12 02:43:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 436164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 855DAC43460 for ; Wed, 12 May 2021 02:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CA9C611AC for ; Wed, 12 May 2021 02:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbhELCpY (ORCPT ); Tue, 11 May 2021 22:45:24 -0400 Received: from mail-vi1eur05on2072.outbound.protection.outlook.com ([40.107.21.72]:55840 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230018AbhELCpV (ORCPT ); Tue, 11 May 2021 22:45:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ErJS1LOAgZZGbLUTF4x8uaZmZjSrpFdtpnArRgUCnWMd3C96eZIr+rHGF+N9/yaFUY+ah8Fbk4OLhStfRC74aH+OnBPfo2b/aou5V3GQ/rZMBr57lnrqDz83n9jzqjDbVTx+EwlsDBbFk6KoxV4JV8KlN9lK6A9UiDcjQFLXTiUNAJnyDIZ+24f+nZ3N2KWZ43BIO2QCJJYUUS9VIFwyA8oawrRlyEdGNbdgB5cNeUamzrpVp6a+BH2PwjmOmuTeLK7myCuOv8ZBr4vPua8mbahyp+qMh51wq3K/+KmsHA+yJknNKzQELh5DCWNtGbdhOBBKR2X4s7NryZXm7pqDvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nhSeP2cChvGtWVl74QmYeG22iZnS3tLE0zWJn2t4SBE=; b=R3MmRzrJl2kWlWdYoVJR476ipRUmHYAx97ed9tnVMMXINacmjyRPXyMw9wq1fm3Ub7YHRF5ztcoaSD7ZxScNED9kCUMn5kX0ZZd4141+hYxQcO5AncRDlDt55M8cteFGJrvvkKlenlau12lNF9vZZQaVv1//eBJz2pCXjfod56SozwZtGFf3Cw4GunOVOkDljMafjDvsG48mUM1gE8tXSrqnhlEo46jdq20lqu4X1gsObHwRicYQzhDdxUZNJNlqpaUVZ5bXgth3BnmaL3oZoHR0ty76gKfXnk/cHpqmE24ViEULuyxMnZRDMrJFrwMm8tAWikNFpILhl9ceGvBIBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nhSeP2cChvGtWVl74QmYeG22iZnS3tLE0zWJn2t4SBE=; b=kkyjQlOdUHe5Kcp/QnSEhRjvu+0DwQxEV8VMWKflu+jzc4TsFMdul7AtR5Psrv7s0y+IIxbv/nfjdAS6SfLy05B4RTUjBP/B0/yMyjBMs5IJxpDa9PDy8sqLJroCjGZKdNebqwGYzEyiPWCG46bYd6+n0GonGHaV0MG9llOSz3E= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB8PR04MB5884.eurprd04.prod.outlook.com (2603:10a6:10:b0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 12 May 2021 02:44:11 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::3400:b139:f681:c8cf]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::3400:b139:f681:c8cf%9]) with mapi id 15.20.4129.025; Wed, 12 May 2021 02:44:11 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/2] net: fec: fix the potential memory leak in fec_enet_init() Date: Wed, 12 May 2021 10:43:59 +0800 Message-Id: <20210512024400.19041-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512024400.19041-1-qiangqing.zhang@nxp.com> References: <20210512024400.19041-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0095.apcprd03.prod.outlook.com (2603:1096:4:7c::23) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR03CA0095.apcprd03.prod.outlook.com (2603:1096:4:7c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.12 via Frontend Transport; Wed, 12 May 2021 02:44:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e6b4e68-957f-4352-fcef-08d914efd2c7 X-MS-TrafficTypeDiagnostic: DB8PR04MB5884: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:486; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8GJlK8hTZardI8hBoicwxo0UqxVWcBzP8qfp7CiHANfK2UMmh4IiGYcKUvj6ggUwHMWOdhOuS5sPlQ1V60+8TYlFgRFK+OsDNy9eCFCIB2MjzwC6fzWTBwrgYpITBBni70ui95+84JByHaVBtDIkxwgwnJVPHDO5EZFBuDe/PIa2/p3fovfl03xjvgQ2uZ6Bd1Ltrx6C1rUpaUXj0gYe/Qy5CO2Jz48k96J0MdLrkEhGqXYu7IXAAsbrwL+QOcAxAio1GOIbZ6YLC1oh14KRiOzuMc/ATAdLa8a6KJCp2eCvrzSonDQpdMvPlBM2T9ZsTp5+9qqyDch8/hnOTviRY5LQbRscSUrfGV0XHFLN45ITtqPrfOSzbN2ECFRSWEzkdbzcaGjuPOXQ6ouGzhT5oZN0j69m9dg/qxl3MIGx5uHjX8wcN+frxHSd4t2vAnogpOcBAajvn6+BmDlhm4uKytzUfvFQrDaJb9MqW6XE0/T1DLfkHi5D+V9SSsv9g+/2OW24zRURFKAhvRoa/0R8HgmiF2W9yzyLhyutzmfj8YJaPwILJ2uEVEbQh8/j7euepqvwzXXyZ2jmWjUVRpRlzemOROudju6D/7A0gbjzz9wK1fZAlgcz+FMHCUCjTqnxgOVsWerCdDRS/5vbrwGfgAltktN47lcz4DEWZI0SqvoiVfcJ/HPdaPhVRF0eWeTy X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(39860400002)(396003)(346002)(366004)(478600001)(2616005)(52116002)(8936002)(5660300002)(86362001)(956004)(4326008)(66476007)(66556008)(8676002)(66946007)(6666004)(1076003)(83380400001)(6486002)(186003)(6512007)(16526019)(6506007)(26005)(316002)(36756003)(2906002)(38350700002)(38100700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4U0ASPBBYUx3pz0rk4kl5IUEJ1i36oiIaXN12Ay07NRTM0xLfGIKvQ6AkNjTz5GpknFY1Q8Y8Yv8fk8v35ZPRiVQgWTQlZXAQCN8gOt/VF8VkMn8G0Ofx9U8E7qznsFDX0KlWW7RAX1uO623jN5rbhos+7zb2FVUa5qE2DxiSScLNruP4jpSCL2kmqLFfvSImHt356FXCd6W9vo5H5AlK8O76Mezv8aovJzetnyjV5hdv6mRrDWWBYVPeg9eGOkcYh9jFh6ZDtXEWBRMVU/wyBPJE6C2TagNRSi3fzrb/ggKk0pxYHxfhYYzhHpjiceMkr36J9nltD4gjdqu0V4T8jkaJBu4iaundgicBlqw0HAbSKkpVLhqrv6lIAFJKqjo4BJn5kJvYS3pGGHQUNMec727KnkOpJdasJf+Yqu3qSWf10EnoWNM6Q1SDi4Km0z1Zgl7HNWBjfIn7lyUZ9pqKpNDMmhAEb1tDhEQOItr8eMj4W8agpTsfrY2c0Qyr7Kp9fO2qVVs3jJT0H9RjiBN0Qmb2GM5AeF/+6aCirC987y7di5QfAhGl8QgCuLsjHYyAUJPTR2JPNvRI4alrdoHbj3G9evzI0uBJ5S+QGcCpFQ6xpOQvDmK7sLGJj37tjx8A978Ft+tjovpOjFKpbuIEwRve6c9EF6cScicRMfWLw559Fd0T9kvbP4wNB+uUyzXMHfcEIYtzeSwhcy9wafUZqoC+Wv3CJCW3zwSfCiIMn4QaoSvkJDDkI8si6baLIICx9jbIasE7gt6rmYGw2HwAxJZRMyktprY+UCpwN7yei9PCqsqpvM0f0Tsigg+vjE/PBcbepOqT4XrCD4B7RdlV723iqAixFLcj9+QUeVoAPCWn2lXq0xW/ei9mzPFo/s3lTBmK7UvMW380HkwvThPxiWPiPM2uB9Y+kcJQbKlO3GfvYagKPIWKe/M8RoWrP50s+XTNSE+8nyERonjJX/Yw+73ObJM+SC4UL91/cHIdd4VElr+g7+8w9ZmocfRsDH/UgtI6mphHcFs6VAQcCGE4BtFv2tgVy9h5Qvvdn5DV9NOJV6fd27T03gK+OrjCJbLRsbF04oKeKZmnfsoN+U24R4+JpF30SgOqxDloN75A3e2ehwvtyoTi6wORGVVvdoYsOFOhhTH79KGetRfYWA99t6mNXXxef7jy/oeJDih4x0VWp9bOR1DoBEg5JNJWIjUDMkL8JZDJRzMiux9g5drrIogYfwFIqvrgAq8yvHzB5koofJBQvQvnjiBV26X2gSZC53+J+ZjC04pS1/rQHWO9r2AwXzW84IMND6rkq7ZCNG6+A/tiO7jhDGPgOjyKgkc X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e6b4e68-957f-4352-fcef-08d914efd2c7 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 02:44:11.8454 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2nNg6yMA9cVqYOCugQ4VLMMPyrVjCCfUPaXTuFnzv4fWVrJlFLpfOuNuKaboMHcE5b03PAuJs3M/FszMPNWY8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5884 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Fugang Duan If the memory allocated for cbd_base is failed, it should free the memory allocated for the queues, otherwise it causes memory leak. And if the memory allocated for the queues is failed, it can return error directly. Fixes: 59d0f7465644 ("net: fec: init multi queue date structure") Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- drivers/net/ethernet/freescale/fec_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index f2065f9d02e6..a2ada39c22d7 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3290,7 +3290,9 @@ static int fec_enet_init(struct net_device *ndev) return ret; } - fec_enet_alloc_queue(ndev); + ret = fec_enet_alloc_queue(ndev); + if (ret) + return ret; bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize; @@ -3298,7 +3300,8 @@ static int fec_enet_init(struct net_device *ndev) cbd_base = dmam_alloc_coherent(&fep->pdev->dev, bd_size, &bd_dma, GFP_KERNEL); if (!cbd_base) { - return -ENOMEM; + ret = -ENOMEM; + goto free_queue_mem; } /* Get the Ethernet address */ @@ -3376,6 +3379,10 @@ static int fec_enet_init(struct net_device *ndev) fec_enet_update_ethtool_stats(ndev); return 0; + +free_queue_mem: + fec_enet_free_queue(ndev); + return ret; } #ifdef CONFIG_OF From patchwork Wed May 12 02:44:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 437765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E000C43470 for ; Wed, 12 May 2021 02:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E90A6101A for ; Wed, 12 May 2021 02:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbhELCpZ (ORCPT ); Tue, 11 May 2021 22:45:25 -0400 Received: from mail-vi1eur05on2072.outbound.protection.outlook.com ([40.107.21.72]:55840 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230129AbhELCpW (ORCPT ); Tue, 11 May 2021 22:45:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P+m6QGIZkOfipaTSAcV497WlhRHtxElsMEch7jdbxwyhbQTjLWkgV2at1OOvWy0CpEvoeJuNtIc7Iu28lGwASzVH7w9+v0uenVm9HKcFCbcq1RZV84Xn7cnl3dAu+Ei9UKnixCRuxsTd170vjxMF8iGE+6+ZlHdhWtZfyqtSSI1PD1oa9qjLKwOa7MoTxCnLN/wkX7EaMMmnkbW34PdC8fTjIDIp32UcIfCT/5Jg6Pt02dz7dNCm+gI/LYA8xgqTZTzOX9u6ZnCWPH74izSpMkcoif6V7DC/UvfaGrZgFB0LlkQI6pPOUEj+jI27nZOPK7P7IdV92UnWhcj7pA8FdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9mKaME+Pz8pAscmf/yjN1bN5qiF0Xdis0xEq7Qe3Lt8=; b=h7Tv1gDsQ2UCx9esWJ1kn5my1vJl2qeM6YmCtKgWGgQ9OIcVMrf+dAypiABpGlejOmm6jVErCeuV2BAfowdOz5/rPgocL3vfe/rmBHOAMASa7QIdz+7LMVe9vQeIHbTVaGkISG3IX7/x4hPvvw2Az3DURvJl8XWXhzGKbm36QwGy5onKZV/R3SWS6gu9hOgCLzp1s6PRA6QhTnSByFvx41E/mGLMt5MbGpiHdK+30Dv8CGkaZ/jhQjoQvvUx4TPcOaCR//TmI+HgNhlA7bqf0EU1GErL+wy/bKqRAjN/t7uLmBshNTbonOP2iLSUINopnNbNpb4KHyLXikXN5OYCHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9mKaME+Pz8pAscmf/yjN1bN5qiF0Xdis0xEq7Qe3Lt8=; b=EbfQ6u2X0GW0PqfDblJud4rhG0unonFz8vjwQ+IU9sOd1u/4+TJKMX8+OUv2sZ36Wt2BtRn1T2d2rPfbNTaeN10IU/v3upglNmzjXTFjFoPvrJ5o/hVNDz4IoJaHGGlgYYfMvNT4bgO8MpRvuufO4rasODu4ngwO5lawaCksXE4= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB8PR04MB5884.eurprd04.prod.outlook.com (2603:10a6:10:b0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 12 May 2021 02:44:13 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::3400:b139:f681:c8cf]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::3400:b139:f681:c8cf%9]) with mapi id 15.20.4129.025; Wed, 12 May 2021 02:44:13 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 2/2] net: fec: add defer probe for of_get_mac_address Date: Wed, 12 May 2021 10:44:00 +0800 Message-Id: <20210512024400.19041-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512024400.19041-1-qiangqing.zhang@nxp.com> References: <20210512024400.19041-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0095.apcprd03.prod.outlook.com (2603:1096:4:7c::23) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR03CA0095.apcprd03.prod.outlook.com (2603:1096:4:7c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.12 via Frontend Transport; Wed, 12 May 2021 02:44:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5b52fc9-ce79-4485-e9f3-08d914efd402 X-MS-TrafficTypeDiagnostic: DB8PR04MB5884: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nSMBxuPk7dYOpxTpf6mXiugjV8GyMCd/GeWqkrqlHQvEmxG+MbqyTKYlFgqLUiKSKOCTC+UdCapEgqLFNx6RaOKNwvvl1zedYe5Gt4A9Vco7bSSiFEpKVMqxfzeFb89j5ajfKyUQTQpoVug4c491WsUbvEkCrjCaaeaIvjLj8WYeM4/gDR+KiXcs2Iof3GVitKf9I01Zlvp17rzFWZv8RWkIA58LUeztxyL4Gsod+fOoui4cMz/z29EV0CQmV59Z04ZxH85OQRk1oQaR5iniOI2xOO0tJLb69IYVxurFkfzaf9H4QZpAb9ola/41UQjRgrRu2xTqwFz7Jw8nB8QTI25CIGEkPJV1iLb2lCEDaW2PlzBS0XmmqUVgyWEK1Uu1DV2GJ6VFeql5DqOh268mWuL61uG7H2azeJhFURAPc6HdyIY7vRvBBt2lSg+SojYpN4EBj833X5VaNFkk4I7XpaI9ta/3gVei47zl0/PPGLfx+B3y+VKV8s/d/wbaYBBCfjjVtedj1OBj1952BXhqHSHn1M9KlLP2yUoHxnvGZTbGJMqpdJfsDH2m5nzyZnnNdV0Sbyw0bGNA1iP7Wcf2oUYBM5J/QZspGXeQ3/SwcyXPiHEqMYd8+DFNHMEY4IXlCad0NMalbkeBQ72tVUiYZ2eCuSJ388U/tRb7xDtibquSAAvV+kK62VjpNZzhpte7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(39860400002)(396003)(346002)(366004)(478600001)(2616005)(52116002)(8936002)(5660300002)(86362001)(956004)(4326008)(66476007)(66556008)(8676002)(66946007)(6666004)(1076003)(83380400001)(6486002)(186003)(6512007)(16526019)(6506007)(26005)(316002)(36756003)(2906002)(38350700002)(38100700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eNayRG1yPE+zGVEyjg8XXJuPOLPnU8NDS3DmtjS1tjsCMyUunfmLLW1nZBuKonrR56NJ9943DwXVBexKCLV3kSxGzk/jxAXzcfUsX9I+d2LQcQ9EPeup0JnqkVVaL3siCtPz7zOWBqZ+yofkLQkWXplZ+3QnGyN+LgDzl1Jspp/KoRISCQZdG6/iKqfcAQnweGrRaQFiw1mcg457O/uS14nsoS9npFhhzCiPQoW0CGxNE5RS90ylXm8madvDNw2e8jd72vazVtH+0msAcRpfD0dRsFnGJLm0I+WDsab5WkQZI/PFTGSXJ6BHthn/wp/TL10r/Nd83JM1vm5UEkf8jd9wrdH0kpn+dnS6s2THenmarcyr4H+QsCws2KCjaasGWeJWtQZlxFFYiozRxcL1gI81O0T2DvlOONLye419+kT02alw6g/gVYaT43QHYZjzDTKXWL25r4DeuopxKIuNYlAfdIBnk3GRUGkzUP10FBiuNIjf7Fr/SvJHS15jrh2X/ne4pDI5wRlHcsCZS+UPI8Q/ibpXAMZPr5ouoIooDbw20PsHZOLHY8WRvTGnJg5ItmviU/K1SQCq4nRPmqND4FYnlqBMSPylG0CkeWtrUUaOzvJsYurvNd6P/dPhzw0rI+brJxIicfHF0CI6qg5imXgfXCnPZV56fyBIP7tJhzd6xdl2Uj945dYx4BCb7TbPcJCkrgm5qZUIZE50pRyMEMw/SeU2D1cEFjBp0ikkhpLJEK+GcFNTCLVTSiZei3GhA7P4PnQiFno4laQ6/LUrRODAcTtNKf/d4xAOEunRd30r6HdoiQqcg1SqPz77+mMUn/asTCr8ZJDpahCxKbZ8hXnEB2fUvqzT+UT8+8H1wHDUaeRWHrMdWaxor6tJrEqBlzBR66QMDtU+tlASKsUtsaRd/6RVPxplxQ4XXF4iqrGVPE8PSFqPdIPXw2sZGIrBA/BeXMIjHE0988jTF6zxrr8W4UbRkA5Jbb3X5Wm8WxfV1XS4GRtei1SKbMsOfIS+ocwnp8OjyqaeXgqFGIxPUILZZnCJ5xt2UXHRDhW1q/9Gi/w/XdKVdQxYyVW5eZ98YKoGj4NWF49b6DLqnLrg73YXv+1H7HTU4W9RzGQi9BAqcJQ9hqVYL4sfSN47hGyJjKYMYk4Hz1E5ARB6EJ5j31NjFJIN7bTPFmNc6PyjXpP8oALGeVtKpzcgr1MfRWRPWgjgX7J42c0ZAlXTtqQGt9vCVrw8J0OyzWWXXaoKFsUlBJC4hnfa9V8fB9waybgH69QWWdEoI5I0mYfTfI0XA17TXWg1pcx2r9Yrd6/muVqe9u+cYCwhHKs18RPW4mfm X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5b52fc9-ce79-4485-e9f3-08d914efd402 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 02:44:13.7809 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Tq0mA7GC6PLOVoeon1ZTCCPpGzJJCxVYLou4OM9KHLUDfUspdh7/IWuJ3JQxn3A9bzXo1iFvZX2j0Z81/2gxJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5884 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Fugang Duan If MAC address read from nvmem efuse by calling .of_get_mac_address(), but nvmem efuse is registered later than the driver, then it return -EPROBE_DEFER value. So modify the driver to support defer probe when read MAC address from nvmem efuse. Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- drivers/net/ethernet/freescale/fec_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index a2ada39c22d7..ad82cffc6f3f 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1662,7 +1662,7 @@ static int fec_enet_rx_napi(struct napi_struct *napi, int budget) } /* ------------------------------------------------------------------------- */ -static void fec_get_mac(struct net_device *ndev) +static int fec_get_mac(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); unsigned char *iap, tmpaddr[ETH_ALEN]; @@ -1685,6 +1685,8 @@ static void fec_get_mac(struct net_device *ndev) ret = of_get_mac_address(np, tmpaddr); if (!ret) iap = tmpaddr; + else if (ret == -EPROBE_DEFER) + return ret; } } @@ -1723,7 +1725,7 @@ static void fec_get_mac(struct net_device *ndev) eth_hw_addr_random(ndev); dev_info(&fep->pdev->dev, "Using random MAC address: %pM\n", ndev->dev_addr); - return; + return 0; } memcpy(ndev->dev_addr, iap, ETH_ALEN); @@ -1731,6 +1733,8 @@ static void fec_get_mac(struct net_device *ndev) /* Adjust MAC if using macaddr */ if (iap == macaddr) ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id; + + return 0; } /* ------------------------------------------------------------------------- */ @@ -3305,7 +3309,10 @@ static int fec_enet_init(struct net_device *ndev) } /* Get the Ethernet address */ - fec_get_mac(ndev); + ret = fec_get_mac(ndev); + if (ret) + goto free_queue_mem; + /* make sure MAC we just acquired is programmed into the hw */ fec_set_mac_address(ndev, NULL);