From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34C8143DEC for ; Wed, 3 Apr 2024 13:55:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 22813402E9; Wed, 3 Apr 2024 13:55:50 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2115.outbound.protection.outlook.com [40.107.21.115]) by mails.dpdk.org (Postfix) with ESMTP id 91D584025C; Wed, 3 Apr 2024 13:55:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lezitjmiCm5DuGTfBydl519qz0xdo1YrBGMu6QYXE4Bh2sP7WsgsHvncHsU0mFqCFGYx4raoKsV0H/R1Y1otPuI88HOGVq8xM2qbJlH0bJk0lW1W6jjR9mh1QvI4JM9dQ7Jd7kGSuOSFaj7XF/8ltPizm18Ai7Tvb79Ret/eBXsiAWbhU0ZYMEPgSwyf0QQ7/BxTMmUPa991AyikmPL3fGJNmu6skSGvxDboU4bvVy1M9bge0vbghZb0oWnWulM1OE3N0Ytqr2XWXTHQmyPQug1TwhbSGdRzXCVxmW28/j6xyYh7MNf8pqroLDwdnjHRd2iENxdGOaRjA59iMjeP6g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JQ0sbb61qytG27HPFycVxfBpDcMKQlMj4wUtufgCxnI=; b=HY6CYmlXR3jyGwzAUUuJQLcm5OVEppegAdsrZmMTtnTQlN81vAG2X3wM3vx+5/EPjcsqbHKrsl3maYse5Y34zWJzgjvJ6z7hT8yBEAmlKJpRNP9Zda/9Q1++0h2YAiMmz/VI5Is2hPxKLNJZ+kcLMuKz7AVJt0eJgAAMvFH955vyeb1IOOb0qj660+xfzRuIt/iWzuF9MECoi/n2ZdXOf5ROla5MXm0eMylujix+2an0rURV5Qb2/O/nhoY5IskDD4KTxzZNhq5iABwOO5zDyoFtACa7Le7HJnbyXd0CA7P1CyzaRoj8uqABfqnLhM1Mm9Yx8o2XIa9MbOUVfsEZlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JQ0sbb61qytG27HPFycVxfBpDcMKQlMj4wUtufgCxnI=; b=tZwYqz0nc//k6vkcaYtl5Iq1zcrt/uZktEGjfuR/w3UYIrmk/HGR6kKLFZ54cmdYJPlEmpTbpSICaCfoA1taIE+sTXad7336ZyL15gVaInLLDyWxi5VO7yq+iL2YYMuhaQ2TRX9jh5nEWix587j/xILgQdL7ERgX/5ufymZqGLmn/kT/JDskAjDzILvFStSPiYHwJaObBE6NmfhWmrv15hD7TiAq2xYmIDKz85TBAlGtesp8JoXXBF1nspPorhVeXX2cl6wyW5L31FRCbqYYDo86T7qGuXDI9lrZoyKFFEyXxOLXzWs8kajfYLjqFwdE7YTw5roL1BVVTh/8fYCwYg== Received: from AS4PR07MB8707.eurprd07.prod.outlook.com (2603:10a6:20b:4f1::7) by DUZPR07MB9744.eurprd07.prod.outlook.com (2603:10a6:10:4d2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 3 Apr 2024 11:55:45 +0000 Received: from AS4PR07MB8707.eurprd07.prod.outlook.com ([fe80::8265:50eb:82ba:6628]) by AS4PR07MB8707.eurprd07.prod.outlook.com ([fe80::8265:50eb:82ba:6628%6]) with mapi id 15.20.7409.042; Wed, 3 Apr 2024 11:55:45 +0000 From: Julien Meunier To: Jing Chen , Jeff Shaw , Michael Qiu Cc: dev@dpdk.org, stable@dpdk.org Subject: [PATCH] net/fm10k: fix cleanup during init failure Date: Wed, 3 Apr 2024 13:55:41 +0200 Message-Id: <20240403115541.2369-1-julien.meunier@nokia.com> X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: GVYP280CA0003.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:fa::18) To AS4PR07MB8707.eurprd07.prod.outlook.com (2603:10a6:20b:4f1::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR07MB8707:EE_|DUZPR07MB9744:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lmS0ZS6jBgZBS20hLk+Ld6FnH12yaAShQ36z8OiYTYIOWkJsxuOE+2Ij0pQofLZvRh+1AoAJrpCeQRpqWU86keplqnUYn4cFI5g5NLU9PdZnT60Banm29Ate79rewPElJFGakcMhM6YC6rL+5AvZ88Pfj7l16/x3qXn5lK6iTlOxubJMgAtJuM5d8I7Giaf+4594d4u+TVvBXnq+bVzmZPaS4YPkqG2nJYjg9Cb0jvZS+6k8+m96m901Ca/cX7XGTPqdVijnoaDXywBMyZHj46qye/9egCdZNBelNGyB1R3ytJHaFlzUXbk16l0Gdd4BtqDVw5uPESCQ6ghssPOOKGhqnPKD1OeETGJXy0zXxcU+JnrgWLJ/xNHkVIAEOgzHJNpFlaRncUbCLb4sJvyAlFzGV2wEm1LP6c+bv29345FOib9pEvEBN4284xOrcL/VAyLFMKnk7QVmJryI1TnYvuVwclX/pU0WNZ0gwKGyWPcpoXk8BakkyXKXRhD+PfpOTakhAY5KfF6DYXTEzc6BaiPAqZ+LVxyznu73I2qELgNS2V7m6BMCuRMJPHx1HOF2J6pdZgqS4eM0+Q0DGp9TgRiEsP3MoXHpQ0O2XKn60oSK1rlChbNheNpWUKacJGTYHD6r1pu43d6FNBpW5koydRcISGt0nBu+937aN82fo9U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS4PR07MB8707.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cLFHnDurrhtKnnlFOMVH2vbwSVv4zD7t21Ia/UM1t2nb+JeVjspBIJAt6Wvz?= =?us-ascii?Q?hYIFw//pGQUgkEAG6XA2AtjabB8ery/wHyoIkxFuoQWnG+3ax5WyasqYUJkW?= =?us-ascii?Q?G5wbQI4fhmy0U/zjQWitZ5zhBCY4kRT/pSOEZ10H2oy2hT99i375siRSbsyy?= =?us-ascii?Q?j2OcRfNkYBl41/y7dVZnONBDVJHhqGYzLypZ8pS0rZ95rDe/Nby27hOun1yT?= =?us-ascii?Q?62VJfL3/c6IJ7rrLwoNbXHnRDDtlt+1MGBXghu75m9ekztcktSv7hlXMg2h+?= =?us-ascii?Q?df2mL04wP6A747rtZdl3hyG3hIokGLK5Tv56LlDf+m5v1exLzVy9q6TxtmQV?= =?us-ascii?Q?65AaI8BXHD1SyZCg2wplyL4vU7zYQkd3hcLiRpEhajQvCd7AhFHJo8b+kuqH?= =?us-ascii?Q?IDDezqBqDgQ896UnmqQ38EHXsf8RWtdCG7jS3HO4X+HBovCtsFKJNpeg2Qij?= =?us-ascii?Q?wrFTPqQRu4C3NmOaYtCSGsK7m2YnX+O540/R5KlrYVPZCsyTxgIn/wpa2fU2?= =?us-ascii?Q?2pV5AwMO5sMS/7Lzls8VGFWCNvWAT4aiMZKpiqhiyx8BRWBvK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pT3gBdWYNxhQrJygv9myGHx6bDY4KC3TuQiw+X9D9wws6bRm?= =?us-ascii?Q?hBJOZW2qzbMqnaTidyzPYAOmPGmhp/WEiQAxB49OZO1ZTXtgPB76BBnqQo5C?= =?us-ascii?Q?VsXA/xsWzvHmJt3VajyL53F47kLU0OWqs+CS9arpqOJoe7P7gk7BxMg64pPf?= =?us-ascii?Q?fw=3D=3D?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce0fff0-3ed5-4e24-ddfe-08dc53d4fe81 X-MS-Exchange-CrossTenant-AuthSource: AS4PR07MB8707.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2024 11:55:44.9737 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yPrDbluzMp5168UagE9Aqm07Wo+wl7qhu6VxvX3LDkg3Uh1i1zYn79nIsFIwduMX7wx50e9nAJrm3aJP3on6kTrhakaRcJBRakEBkvAoZj8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR07MB9744 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Cleanup was not done on this PMD if a error is seen during the init: - possible memory leak due to a missing free - interrupt handler was not disabled: if an IRQ is received after the init, a SIGSEGV can be seen (private data stored in rte_eth_devices[port_id] is pointing to NULL) Fixes: a6061d9e7075 ("fm10k: register PF driver") Fixes: 4c287332c39a ("fm10k: add PF and VF interrupt handling") Cc: stable@dpdk.org Signed-off-by: Julien Meunier --- drivers/net/fm10k/fm10k_ethdev.c | 39 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index fa0d16277e..7b490bea17 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -3058,7 +3058,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = pdev->intr_handle; - int diag, i; + int diag, i, ret; struct fm10k_macvlan_filter_info *macvlan; PMD_INIT_FUNC_TRACE(); @@ -3147,21 +3147,24 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) diag = fm10k_stats_reset(dev); if (diag != 0) { PMD_INIT_LOG(ERR, "Stats reset failed: %d", diag); - return diag; + ret = diag; + goto err_stat; } /* Reset the hw */ diag = fm10k_reset_hw(hw); if (diag != FM10K_SUCCESS) { PMD_INIT_LOG(ERR, "Hardware reset failed: %d", diag); - return -EIO; + ret = -EIO; + goto err_reset_hw; } /* Setup mailbox service */ diag = fm10k_setup_mbx_service(hw); if (diag != FM10K_SUCCESS) { PMD_INIT_LOG(ERR, "Failed to setup mailbox: %d", diag); - return -EIO; + ret = -EIO; + goto err_mbx; } /*PF/VF has different interrupt handling mechanism */ @@ -3200,7 +3203,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) if (switch_ready == false) { PMD_INIT_LOG(ERR, "switch is not ready"); - return -1; + ret = -1; + goto err_switch_ready; } } @@ -3235,7 +3239,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) if (!hw->mac.default_vid) { PMD_INIT_LOG(ERR, "default VID is not ready"); - return -1; + ret = -1; + goto err_vid; } } @@ -3244,6 +3249,28 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) MAIN_VSI_POOL_NUMBER); return 0; + +err_vid: +err_switch_ready: + rte_intr_disable(intr_handle); + + if (hw->mac.type == fm10k_mac_pf) { + fm10k_dev_disable_intr_pf(dev); + rte_intr_callback_unregister(intr_handle, + fm10k_dev_interrupt_handler_pf, (void *)dev); + } else { + fm10k_dev_disable_intr_vf(dev); + rte_intr_callback_unregister(intr_handle, + fm10k_dev_interrupt_handler_vf, (void *)dev); + } + +err_mbx: +err_reset_hw: +err_stat: + rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = NULL; + + return ret; } static int -- 2.34.1