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 BE58941E28; Fri, 10 Mar 2023 04:17:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0FB541140; Fri, 10 Mar 2023 04:17:05 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id A21BF41143; Fri, 10 Mar 2023 04:17:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678418223; x=1709954223; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=/UjLDx7N8rvzYM1+kZIEeK9XvqfvbirhqV7Ck2zUqSw=; b=cesFQWeabpNPhHyHylAK1r0KWJwawvAByg9QR1RhrAchRk1iluQqc86z GjlhhCmVlw41CF5gbvxjhwEnlUfh4ZTll7czhtPMSABL808yUZl+EAGgo KgewsTy0tNurPZfXBs2D2WjDL7DDFrRV/as33dnPEbutShe1w4RAc9HWe rFgndALkDrutSevonNkcDmmonSuzNbgSEjAY8iGEDyM74KoqvUEZmWGiN RACSrcVk+VRQ8QbskIzS3jrSwbxFx4+7dSXCS8k7GQwiqDeiYjkA2fFCW lTxaslbpiUSRiRW1R/ewbbJlWY049aBSysi08FOcapZHApDRqXWymL1og w==; X-IronPort-AV: E=McAfee;i="6500,9779,10644"; a="334111513" X-IronPort-AV: E=Sophos;i="5.98,248,1673942400"; d="scan'208";a="334111513" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2023 19:16:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10644"; a="670944069" X-IronPort-AV: E=Sophos;i="5.98,248,1673942400"; d="scan'208";a="670944069" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga007.jf.intel.com with ESMTP; 09 Mar 2023 19:16:54 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 9 Mar 2023 19:16:54 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 9 Mar 2023 19:16:54 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 9 Mar 2023 19:16:53 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSAEbSSl8a2KcUqpu91JtLxzAaMetdRAVp7GpxTZCUoy6ysujBFl/hMF90IE3UK2tFiaovXsIRtepKjLjon20BTOlsyXk3ebvdvWC2ynZ+amUbe8+YPIqwhuysOyKF5BAO3zc/Jvlv3sqVPqib4RTrBLSY/hB90YUBuAwy41afSW5n9hzolvuBdhnl9uOf5vPAgC8mcqyMsIpACMZdv5xcSN8974JAA4lnBGMJmN1YgjBClcjo91rfoqxG4vmLyRpGq4iRY7pC702mbS1MD28CvNg972nejoJMhvgiB4MwSi2cMoLoMhpNOsj5bPAUmA0MG1b9LLuGlSRL1Ucjs/eg== 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=PVoMtWgunMy6gt9R5s41/CbdkEg89JjYIHuhdWarxkY=; b=X4fWOOsMv/hhGcnBEb7LtJ13zfAWOAK83hqXe776WBwmeYtmKrCYacXXjrrkErCRCo+KN/RKKqeGw65JhxHKvd9mHB7b//iFRFSdqlBkR5Y6Y5/KCh8KhJzl+d9QjB/TI7uFV9uIXhaPfJenodZcy/miJjEsFlWmBSKnA1xaAhEPJZEBfzP6PkYIRPO6zxnmSt1oqf6TbMs+tPI0SzvYr2i6g7buf+0BosLdTQC6M/ft1pdWKG28oYsCX5HYOfPUJpgGDMw21MzfcaRyiJ1sj6beKSdtqvSIr24kB9vmSXYBuQF+QBNB3do3T9CSuIxLh06rnDDGRMtFE/9kkWshgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by MN0PR11MB5987.namprd11.prod.outlook.com (2603:10b6:208:372::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 03:16:52 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc%3]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 03:16:52 +0000 From: "Xia, Chenbo" To: David Marchand , "dev@dpdk.org" CC: "stable@dpdk.org" , Maxime Coquelin , Hyong Youb Kim , "Harman Kalra" Subject: RE: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup Thread-Topic: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup Thread-Index: AQHZUoQHZnxppmU0V0G+QPhkoExYf67zWG+w Date: Fri, 10 Mar 2023 03:16:52 +0000 Message-ID: References: <20230309123752.2237828-1-david.marchand@redhat.com> <20230309123752.2237828-3-david.marchand@redhat.com> In-Reply-To: <20230309123752.2237828-3-david.marchand@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|MN0PR11MB5987:EE_ x-ms-office365-filtering-correlation-id: 5d343e37-171e-438d-4a32-08db2115e547 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lPy9/n8cUGh8f6wDJbAd5w4ZUCnY7voMQzeo1N5Gfqeo5VBoF2VXYpIl+blxjZl6gLrQ9VBs5L/lR2WIDvyGyOl+hqkL/nM96qHvOFJ8jVDqBN/o1gCQnQUfbJq6SfrHNBU4hux7B3wRIPqxgu4PPfHswIIesonUeiChdootdILHKuQ7yqbfUk5Uc906tRW8f5SQA+3fllWVOppa0glpC+kl4OzjEeBKGozWSIRNx7wKNpOylOKs8E1AGMhK1hpe0S2VQK75rheTWagBcxJPaTR04qQZBMhwcK7Mg8lN0yopOC/PAVcywdFBC0yQxXT1k4zPLvzuozW/tOR346Ugcu1vFkgN+pwDDroCMMXQKl1hYYy+K2F7k1OaDT0w4pFe95zLmcAa0ewcntQx4HAm3SPmiLFbF0Ku5+b+GFHdKN7q3ckJDIjdRbTRNYJhVP9ooWSNg3ox7+KJS/MCk3QI3U0gYJzQU6XEwBLzGfetmQXX/vDu8MoQ6qZ/2HNP1BZiONIGLoWeQJioqrQpjSlyProTsWjLUAgiGZ+zoSAR5QDg/2IHbu4vaBXdWoW74giRdlzVnJs74qvRfkUcHw+Nmpu433Ki4H9/mB6uKh1bxywNPGhlDBF+QsoBTxkJRwHivCh86V/iy8x/HXfMfGC3nyUZZW8IT9g94psM4+wVa13HMk/umkKApf/sPE5P1p0pYV0nqykjhtWiUa9sUMwCKQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(136003)(39860400002)(346002)(396003)(376002)(366004)(451199018)(66446008)(66476007)(64756008)(66556008)(76116006)(66946007)(8676002)(4326008)(9686003)(53546011)(6506007)(122000001)(186003)(26005)(83380400001)(316002)(54906003)(110136005)(478600001)(86362001)(33656002)(2906002)(55016003)(71200400001)(38100700002)(38070700005)(82960400001)(7696005)(41300700001)(5660300002)(52536014)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Mcj8HR32LLA6knpwWNeOCySO+owaLIWiI/kiVgjjALXxAsMShQPu4BSRoeph?= =?us-ascii?Q?v1vkNzCcZpG/baX+GZzlIE2WRZlRpLXgOvnwTGum62RfJZkNZfCOq7zBUJlb?= =?us-ascii?Q?7wYb/PD3N7DPudGeIiwKnkHAJFATsxBSqsmtIZzV4WIVLx1dL+V90GtFQhNd?= =?us-ascii?Q?GWpgdG8DoUiGcFcnQRh3hVQavBbhV/vgw2twqmf0jkR0pnxqIp8967O/P2gu?= =?us-ascii?Q?FLABGfyxl2ZXuKJuOCaMMwjicMfyIMGTNr1ZN9a7hNxwArMSNqtkRcp/X21T?= =?us-ascii?Q?1icqnBxg6StWxWKXPvoy47UtWtxazUwyCQNtPya7IQVZBmPfdo6VmN+2ULGx?= =?us-ascii?Q?sy8bQdhorE+zUX4Kk0jO5A8FMgv8uX7FHqQHsSW3YjdvI1sEUwYf4T2W+kbb?= =?us-ascii?Q?BbCILRabOFgn1TCaG8bd4tu0AvEe/7ax5hzyKbPNM7I4AacGan3faz7WCT3X?= =?us-ascii?Q?39gj4uFh8TAnQrnUwpdJCY59hxpoI7EWP67nQep5BjC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ua3KJFufIiVxhlpcCHcgkPl4khyq+tFKrgPA3lc?= =?us-ascii?Q?W5HSTJVWN3aocztCXPlRf7wLkXqkPP5ItxZKPoAlRQbEFPAsSL05ht1mCSWp?= =?us-ascii?Q?n7swI/Cqts5b7kdcLWARJxBvOTiZJGLW05zi0smajJ4YICaa+dBFSgI1c8wK?= =?us-ascii?Q?35i8rYBEp2tObosqIO3tQF61zZ05eFVyZXplfTYl?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d343e37-171e-438d-4a32-08db2115e547 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2023 03:16:52.7585 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bXU2coBhDni/d7Jts1uymCmNx4rhu+Z3aZoBwkXkdJfEZXNlomZOQxoumLwuZEUXYAom/0bHFhzb9HtjBvjspA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB5987 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: David Marchand > Sent: Thursday, March 9, 2023 8:38 PM > To: dev@dpdk.org > Cc: stable@dpdk.org; Maxime Coquelin ; Xia, > Chenbo ; Hyong Youb Kim ; Harman > Kalra > Subject: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup >=20 > Do a systematic cleanup if any part of the interrupt handle setup fails. >=20 > Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle") > Cc: stable@dpdk.org >=20 > Signed-off-by: David Marchand > --- > drivers/net/vhost/rte_eth_vhost.c | 53 ++++++++++++++++++++----------- > 1 file changed, 34 insertions(+), 19 deletions(-) >=20 > diff --git a/drivers/net/vhost/rte_eth_vhost.c > b/drivers/net/vhost/rte_eth_vhost.c > index 198bf4d1f4..96deb18d91 100644 > --- a/drivers/net/vhost/rte_eth_vhost.c > +++ b/drivers/net/vhost/rte_eth_vhost.c > @@ -686,25 +686,32 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) > dev->intr_handle =3D > rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); > if (dev->intr_handle =3D=3D NULL) { > VHOST_LOG(ERR, "Fail to allocate intr_handle\n"); > - return -ENOMEM; > + ret =3D -ENOMEM; > + goto error; > + } > + if (rte_intr_efd_counter_size_set(dev->intr_handle, > sizeof(uint64_t))) { > + ret =3D -rte_errno; > + goto error; > } > - if (rte_intr_efd_counter_size_set(dev->intr_handle, > sizeof(uint64_t))) > - return -rte_errno; >=20 > if (rte_intr_vec_list_alloc(dev->intr_handle, NULL, nb_rxq)) { > - VHOST_LOG(ERR, > - "Failed to allocate memory for interrupt vector\n"); > - rte_intr_instance_free(dev->intr_handle); > - return -ENOMEM; > + VHOST_LOG(ERR, "Failed to allocate memory for interrupt > vector\n"); > + ret =3D -ENOMEM; > + goto error; > } >=20 >=20 > VHOST_LOG(INFO, "Prepare intr vec\n"); > for (i =3D 0; i < nb_rxq; i++) { > - if (rte_intr_vec_list_index_set(dev->intr_handle, i, > RTE_INTR_VEC_RXTX_OFFSET + i)) > - return -rte_errno; > - if (rte_intr_efds_index_set(dev->intr_handle, i, -1)) > - return -rte_errno; > + if (rte_intr_vec_list_index_set(dev->intr_handle, i, > + RTE_INTR_VEC_RXTX_OFFSET + i)) { > + ret =3D -rte_errno; > + goto error; > + } > + if (rte_intr_efds_index_set(dev->intr_handle, i, -1)) { > + ret =3D -rte_errno; > + goto error; > + } > vq =3D dev->data->rx_queues[i]; > if (!vq) { > VHOST_LOG(INFO, "rxq-%d not setup yet, skip!\n", i); > @@ -729,16 +736,24 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) > VHOST_LOG(INFO, "Installed intr vec for rxq-%d\n", i); > } >=20 > - if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq)) > - return -rte_errno; > - > - if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1)) > - return -rte_errno; > - > - if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV)) > - return -rte_errno; > + if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq)) { > + ret =3D -rte_errno; > + goto error; > + } > + if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1)) { > + ret =3D -rte_errno; > + goto error; > + } > + if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV)) { > + ret =3D -rte_errno; > + goto error; > + } >=20 > return 0; > + > +error: > + eth_vhost_uninstall_intr(dev); > + return ret; > } >=20 > static void > -- > 2.39.2 Reviewed-by: Chenbo Xia =20