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 042BBA0A0F for ; Wed, 7 Apr 2021 17:16:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E81AA140FB2; Wed, 7 Apr 2021 17:16:11 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2040.outbound.protection.outlook.com [40.107.20.40]) by mails.dpdk.org (Postfix) with ESMTP id E30AA406A3; Wed, 7 Apr 2021 17:16:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vBnYyKMpj6iAfmrbDO4KCfTHILIsoN4WroH7TnpmQjY=; b=NBsL+TEYu8hADzBo9O1f5y7uBH2HXS6PCO+I/kn6qUgkapWhGZa2FQpfo3wbV4sNE3dl35+clCpF1wRxrajMhb3DgRjacReaDY9XCSEUuYlkY3z9Nm1L/OzqY/slnDXqhD3IO3M4GCumBNGJVWvJpaLur449eCKDO1pCPoZkSBw= Received: from AM5PR0201CA0005.eurprd02.prod.outlook.com (2603:10a6:203:3d::15) by VE1PR08MB4912.eurprd08.prod.outlook.com (2603:10a6:802:a9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Wed, 7 Apr 2021 15:16:07 +0000 Received: from AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:3d:cafe::6) by AM5PR0201CA0005.outlook.office365.com (2603:10a6:203:3d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 15:16:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT022.mail.protection.outlook.com (10.152.16.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 15:16:07 +0000 Received: ("Tessian outbound 81a4524e9a48:v90"); Wed, 07 Apr 2021 15:16:07 +0000 X-CR-MTA-TID: 64aa7808 Received: from 86a55324b372.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 422F1D99-B5FB-4F7A-A38D-EE3C53E8CFB2.1; Wed, 07 Apr 2021 15:15:56 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 86a55324b372.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 07 Apr 2021 15:15:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5Wc1AUEb6Y2HJIQexAI0DfAb3PVfIH0sj2jKB/pZHtogcEi36vk6RMIIBAGXBiutasIYeRE0zh0munnnaY5PksWLUOjQTGxxbRu0/YvJk9nDHavvNt3BiXYDM9Rz2UXhlt+3b0Il3uAiPlXZ5JzVc9cjJX0QYwNb1UqX8+KJ9uf9f8TTHkHuMPe1omMPNLVWyCN3/L7A3fFJvGu1TOtTHDeDba2PYj+apXxw44kJETmB2vR7clnG8jSd5YGQ9TXQ+Agx7SsFCt4ZJA6+Xj3zBwgoE9B7tvGxZCXNVZPfVL5frn1epJcjJcIfHDJNt8YBHCjG/yuELDaLIttFT4KRw== 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=vBnYyKMpj6iAfmrbDO4KCfTHILIsoN4WroH7TnpmQjY=; b=AyLwv6LdMuv+JAXY2xfrtosmDZMEJs8yfH6ePMKsCyDjpBgNMrTvlgcZmXpbjJZHJNTEaF7LmZqjBUURbQklecVGBY62a+mhlJC7vwMzLJYaxUoEOByug46HtdpMBetdo/ya6Ag1Kaak21PddckdPNA+lRxplygmKjXJb76NcwZpxJSFjmz8vGh1x6PH+HtlFIxpZ4STXFPkIvpXoyKkYJHCeBiJT1pcqnDDIVQjPRnG55nvjYMNG3qQatpGY4YocxyMRmH0xODE7sXvunBX41ICqE25CjngJhE6pUR1mfAkGRfeK3Gv3Rk2bA9bLmcIW56xHMEOGCMG0b6gqKsbpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vBnYyKMpj6iAfmrbDO4KCfTHILIsoN4WroH7TnpmQjY=; b=NBsL+TEYu8hADzBo9O1f5y7uBH2HXS6PCO+I/kn6qUgkapWhGZa2FQpfo3wbV4sNE3dl35+clCpF1wRxrajMhb3DgRjacReaDY9XCSEUuYlkY3z9Nm1L/OzqY/slnDXqhD3IO3M4GCumBNGJVWvJpaLur449eCKDO1pCPoZkSBw= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by DB9PR08MB6698.eurprd08.prod.outlook.com (2603:10a6:10:2a2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17; Wed, 7 Apr 2021 15:15:53 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::2994:a01e:2de:f94e]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::2994:a01e:2de:f94e%7]) with mapi id 15.20.3999.032; Wed, 7 Apr 2021 15:15:53 +0000 From: Honnappa Nagarahalli To: Olivier Matz , Luc Pelletier CC: "jianfeng.tan@intel.com" , "dev@dpdk.org" , "stable@dpdk.org" , nd , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v5] eal: fix race in ctrl thread creation Thread-Index: AQHXK61Rx3tzBD13sky/GZy9uKscq6qpDSqAgAAZ/2A= Date: Wed, 7 Apr 2021 15:15:53 +0000 Message-ID: References: <20210407123529.123899-1-lucp.at.work@gmail.com> <20210407125322.124327-1-lucp.at.work@gmail.com> <20210407133105.GL1650@platinum> In-Reply-To: <20210407133105.GL1650@platinum> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 189E39CF7A7CAF4AAF6BF0DDFF995B71.0 x-checkrecipientchecked: true Authentication-Results-Original: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.113.13.105] x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 28d3d2f8-8358-4de5-5b15-08d8f9d81174 x-ms-traffictypediagnostic: DB9PR08MB6698:|VE1PR08MB4912: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4303;OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 18qsvKt+i0GKNDGR/vhg+fAMjS6ZoSpcB76ievN/zFzP6XbOoowT5HVO9XR2x63e7deE/BBzTPUtSloHW8DJcNg2hmwM2RAkW/XlIZFKUwF+bkyvDpGhSSYgIdV12hLJi3+BVCwypIAlQPKhWtzIY5FJuyWUBPuR843gxac5OMoY0X7RpmiVvIJ4he/zTGlU5vq0fSi3inOgprWUOUIR9buVGcy2xDskbLSMAh2RJfu6CLgmhy5hrPqJdufVMsCNC5mh4LL7R4r3+idunhP2/zKau+TQiwfx1LJfRQ839NOygex9Skfq0y6DxoOPqD0BnerlWkVyJ2UqrZqg2VZy0IboTmAQiKjiWA1YOrvpslW1K+VMAD1JI7DyCyS6ZxCr96PL8heIUf2WbWhIULRGIyvICqMXvLjpJDYZ+VqGtTZ7OxkDvkvj/4uPb694XUhWv3etat2YhIAPpLEtW55K2X7cQz9qNb5XQmGiF/k5xmCxcXTxdDVMaPfwdu7FZpSVqdUxtPmxp5RIy4WHxaIxJRL2jK0Ies9go4r1cIoKXDoD1jJUbo+1KCUHzhuxZKSHNLwwa63kKlmOQcRf2KVEja/aBssA/fW6zkKgqL/L/5lwFUmbZg6GSuz+pmH434w0OXHiSnuEaNxSitY3SyAVsHZlb1zUtBhaDnPfPL7UoRQ= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(396003)(136003)(366004)(346002)(39860400002)(9686003)(8936002)(7696005)(86362001)(110136005)(83380400001)(2906002)(6506007)(186003)(55016002)(71200400001)(54906003)(478600001)(4326008)(52536014)(26005)(38100700001)(76116006)(316002)(33656002)(66556008)(66946007)(66476007)(5660300002)(66446008)(64756008)(8676002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?+mffdRzdyX6crCIgbhfSieZvUnOxxuQMe6xiNDnC37hNKDl8bv1jCSYLANts?= =?us-ascii?Q?63UvwqNfiBr60kCPsNZFTfRlsYc8y2a4hpPaua2JOvmZG0vF6mE5Jc+NaZkl?= =?us-ascii?Q?xkuFKSCCYz1Bl5lpY70WJ+8z0aA7d6fSkvGhleYPe3Yafw88OPKyXgLK0T/E?= =?us-ascii?Q?exjWxLuS44hfy3bvjNW3dWtbHRX1mrWfHdQjX7G5kWq3mLBAhl2QKSsWhsNR?= =?us-ascii?Q?4Ac6eKIzWIjzQYF1kiVlCYLlFHzPxigElJ+lQrazmy/twAhjTkx5bP/VwBkc?= =?us-ascii?Q?YWAgaVQmKKiKv5vQ17XbnZ27sRoLzpo1A5Ie/Iz4RxwduNzFW17ZTvBvDJK3?= =?us-ascii?Q?Rn4h0uKDF6GB6JmLS6Rjs7m/buI5L0z78Dox+bNWvuLYe3x8RGE9XXLpiOtE?= =?us-ascii?Q?fwKuswTwA1HL/zqEAaFOzGWHSmgC+kZGahiUUu+6crWXUQV25TjQ/gmgTrH2?= =?us-ascii?Q?PmJxGj8mRPQHHFpan1s2rZYxQ/WaLKeHDvTHUxv0Fwp6UX0FdLtWYIpD9OCJ?= =?us-ascii?Q?0DaYOT7rfO8fS3X6iyl+hmuTwkB5O6T3A3esDyxj2Nq5gP3FcVAQOgB4BpQt?= =?us-ascii?Q?ZRkz0GSiZ16PD1N5rRNinCCS2ArCsb/2My9DuzimyLlXqkK82odxegXg3cXw?= =?us-ascii?Q?XLQV0EC2D6v3kY9P9+abeCnOhQ1stcg1iK7BgXFiFv+ZLP2cb2SglEnV4GFg?= =?us-ascii?Q?Lx5uD0LunkZi1W7ktNRvunGf+qnGdigegjpPgr6dICX1ZRApeLVgEevrLsQm?= =?us-ascii?Q?Rvf3WBjUiSMiwsjGXpKxWzA+22XSPgWOYwetQGJDLQxYKzqerJavbSzRrbyU?= =?us-ascii?Q?vUfHXPgFTAKE1+uNPz7Arz/FHbMgn8JLsvTHHhJuhC9oyjXbmfsLNa0w1xXh?= =?us-ascii?Q?G+FR/NzAsBDsuo5aQUZC9ptJgiyNh430xS/XFwTicg87Nt3tJv/PDl5JptSw?= =?us-ascii?Q?qiD3SmWoylLxdPcsIij1TUEizNOM69jtgPISVELNebGOlwwRrf/J0dA1djqE?= =?us-ascii?Q?DhYbTaUObcOrtvzu1niJ09I5etuOIO4gV0ldt7+J75JUrkfDWNHRLNoqO4GX?= =?us-ascii?Q?y9qkzvSkkW5hvi3ZsvwFba6t/1a7CgESMlzqwDcBI9lJ32zEa0UApcVNk3b2?= =?us-ascii?Q?UCN0HbtNvV18K3rxx8rX89rB3Gjzp8T31ZrC8QwbfrvoGFJ7K0o89WVDCdS3?= =?us-ascii?Q?SqFTtrwSshhoKhIj0uHzKmmaFz6h/Z7OXUVYFIsvOHqE/0Lnep5bU0mwLFwW?= =?us-ascii?Q?ZkQfnkOhBXzDVyVmmmf28dP9en/LaFqFdWyTwSh+rTvQ91W1b50vq/8ldYDg?= =?us-ascii?Q?Y+3q+sHFBJz9I/9kR25LlYRZ?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6698 Original-Authentication-Results: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e907a768-19ca-4251-396e-08d8f9d80965 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iV192/R5uJAezboXp1XQqJZMCSZevE+kZ4ys1t5eYAf8pziE8VBXGcaaz5iaTplq+J/qgpTXOu0f/w+OL8tLIqb9nl/qVnJGLN1uI5SOgKufuQ5lPmoVjM+YtZMohOSUta18qlmGyL+Vgkl+uJFIT1y/IVjmbFLtFfGgrXqd0dsi26lJEoFd/aHGKUCycHfmHe1xiTGNPY68xetJDVgsvqSuzlyUHtE7QE+IKqHC2uDyheqSx8GhOJgE8EDTQyf6OK2Xvb96p8SMSKP5fMPp0qhHn+1ZntCjg3F7hvQRhLwk9F1g0MvfE3DN7rRGNlk0NFUqBBhAveMyvActQxFJU9bpwaiqV8s2sRHSEmLGjlb6PS+PorJEKqeL77d2hesV0F0+td2cnmANLJs4w9wkit1ioACDslUlZHv8xzVk5ZODKekDmje/z90yTzJtVf47YOhpT1zsk2J67kyXSIBOnx/el6dLVAsZNas9UzH+wlMZdxxHNE0j0vZBS7Z2fCsmRC/4+5qWCItpreE2ZomN0KP1YU7w5dUGd3idS+aoa+S2JpAehNiIM2vN58afA1fEV2D4Y6gPxHNlAgqYtAA3uV3hrP5JrtCrgnNT9bw7WjvHBuu6v1oW7AAZll6nz8JEHs2C+eei4USFUk/hTj9Ckw== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(39860400002)(136003)(376002)(346002)(396003)(46966006)(36840700001)(8936002)(70206006)(70586007)(2906002)(186003)(6506007)(81166007)(5660300002)(82310400003)(8676002)(83380400001)(55016002)(47076005)(7696005)(33656002)(26005)(110136005)(86362001)(4326008)(36860700001)(9686003)(478600001)(316002)(356005)(52536014)(82740400003)(450100002)(336012)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2021 15:16:07.3175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28d3d2f8-8358-4de5-5b15-08d8f9d81174 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4912 Subject: Re: [dpdk-stable] [PATCH v5] eal: fix race in ctrl thread creation 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 Sender: "stable" >=20 > Hi Luc, >=20 > On Wed, Apr 07, 2021 at 08:53:23AM -0400, Luc Pelletier wrote: > > The creation of control threads uses a pthread barrier for > > synchronization. This patch fixes a race condition where the pthread > > barrier could get destroyed while one of the threads has not yet > > returned from the pthread_barrier_wait function, which could result in > > undefined behaviour. > > > > Fixes: 3a0d465d4c53 ("eal: fix use-after-free on control thread > > creation") > > Cc: jianfeng.tan@intel.com > > Cc: stable@dpdk.org > > > > Signed-off-by: Luc Pelletier > > --- > > > > Same as v4 except that I fixed 2 minor style issues flagged by patchwor= k. > > > > lib/librte_eal/common/eal_common_thread.c | 52 > > +++++++++++------------ > > 1 file changed, 25 insertions(+), 27 deletions(-) > > > > diff --git a/lib/librte_eal/common/eal_common_thread.c > > b/lib/librte_eal/common/eal_common_thread.c > > index 73a055902..c1044e795 100644 > > --- a/lib/librte_eal/common/eal_common_thread.c > > +++ b/lib/librte_eal/common/eal_common_thread.c > > @@ -170,11 +170,19 @@ struct rte_thread_ctrl_params { > > void *(*start_routine)(void *); > > void *arg; > > pthread_barrier_t configured; > > + unsigned int refcnt; > > }; > > > > +static void ctrl_params_free(struct rte_thread_ctrl_params *params) { > > + if (__atomic_sub_fetch(¶ms->refcnt, 1, __ATOMIC_ACQ_REL) =3D=3D > 0) { > > + pthread_barrier_destroy(¶ms->configured); > > + free(params); > > + } > > +} > > + > > static void *ctrl_thread_init(void *arg) { > > - int ret; > > struct internal_config *internal_conf =3D > > eal_get_internal_configuration(); > > rte_cpuset_t *cpuset =3D &internal_conf->ctrl_cpuset; @@ -184,11 > > +192,8 @@ static void *ctrl_thread_init(void *arg) > > > > __rte_thread_init(rte_lcore_id(), cpuset); > > > > - ret =3D pthread_barrier_wait(¶ms->configured); > > - if (ret =3D=3D PTHREAD_BARRIER_SERIAL_THREAD) { > > - pthread_barrier_destroy(¶ms->configured); > > - free(params); > > - } > > + pthread_barrier_wait(¶ms->configured); > > + ctrl_params_free(params); > > > > return start_routine(routine_arg); > > } > > @@ -210,14 +215,15 @@ rte_ctrl_thread_create(pthread_t *thread, const > > char *name, > > > > params->start_routine =3D start_routine; > > params->arg =3D arg; > > + params->refcnt =3D 2; > > > > - pthread_barrier_init(¶ms->configured, NULL, 2); > > + ret =3D pthread_barrier_init(¶ms->configured, NULL, 2); > > + if (ret !=3D 0) > > + goto fail_no_barrier; > > > > ret =3D pthread_create(thread, attr, ctrl_thread_init, (void *)params= ); > > - if (ret !=3D 0) { > > - free(params); > > - return -ret; > > - } > > + if (ret !=3D 0) > > + goto fail_with_barrier; > > > > if (name !=3D NULL) { > > ret =3D rte_thread_setname(*thread, name); @@ -227,25 > +233,17 @@ > > rte_ctrl_thread_create(pthread_t *thread, const char *name, > > } > > > > ret =3D pthread_setaffinity_np(*thread, sizeof(*cpuset), cpuset); > > - if (ret) > > - goto fail; > > + pthread_barrier_wait(¶ms->configured); > > + ctrl_params_free(params); > > > > - ret =3D pthread_barrier_wait(¶ms->configured); > > - if (ret =3D=3D PTHREAD_BARRIER_SERIAL_THREAD) { > > - pthread_barrier_destroy(¶ms->configured); > > - free(params); > > - } > > + return -ret; >=20 > I think not killing the thread when pthread_setaffinity_np() returns an e= rror is > not very understandable from the API user point of view. Agree. >=20 > What about doing this on top of your patch? The idea is to set start_rout= ine > to NULL before the barrier if pthread_setaffinity_np() failed. So there i= s no > need to cancel the thread, it will exit by itself. How about using the pthread_attr_setaffinity_np API? It is deviating from the documentation of the 'rte_ctrl_thread_create'. But= , from the user perspective, the behavior should not change. This way we do not have to handle the error after the thread is launched. >=20 > @@ -187,14 +187,18 @@ static void *ctrl_thread_init(void *arg) > eal_get_internal_configuration(); > rte_cpuset_t *cpuset =3D &internal_conf->ctrl_cpuset; > struct rte_thread_ctrl_params *params =3D arg; > - void *(*start_routine)(void *) =3D params->start_routine; > + void *(*start_routine)(void *); > void *routine_arg =3D params->arg; >=20 > __rte_thread_init(rte_lcore_id(), cpuset); >=20 > pthread_barrier_wait(¶ms->configured); > + start_routine =3D params->start_routine; > ctrl_params_free(params); >=20 > + if (start_routine =3D=3D NULL) > + return NULL; > + > return start_routine(routine_arg); > } >=20 > @@ -233,10 +237,18 @@ rte_ctrl_thread_create(pthread_t *thread, const > char *name, > } >=20 > ret =3D pthread_setaffinity_np(*thread, sizeof(*cpuset), cpuset= ); > + if (ret !=3D 0) > + params->start_routine =3D NULL; > + > pthread_barrier_wait(¶ms->configured); > ctrl_params_free(params); >=20 > - return -ret; > + if (ret !=3D 0) { > + pthread_join(*thread, NULL); > + return -ret; > + } > + > + return 0; >=20 > fail_with_barrier: > pthread_barrier_destroy(¶ms->configured); >=20 >=20 > Regards, > Olivier