From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E3876A3201 for ; Mon, 21 Oct 2019 07:01:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE3042B86; Mon, 21 Oct 2019 07:01:09 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60089.outbound.protection.outlook.com [40.107.6.89]) by dpdk.org (Postfix) with ESMTP id 9FDDDF04; Mon, 21 Oct 2019 07:01:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWv5oIHvtsNgw3KLDEHYu7lIqXMtPilhP/QjxWYuh+LYLs58tsqsHrzYAJC13rQfxthHIpmT3111ob6HAM2boBz/SVogjtcJG2UIQy8HkBhpSXgU2sMoHPfz2rmA69W7c39uTQUUZ7TVVmqT7vwqB9fS3cO56Et5ypovFMlgxatnMJNv1fASebmi3urjm9M+7cgHvClZoefuCzHDW3B6lo8keQbkYhBR1MPwToFEWp0ewpV7p/0zAUd23deBjQEcWLwNiSFBpgMUFQ2qmDROcHuE+QeIK27OEBCaB3UQlrYd+PNUvqHaBAznTEHW23N+XINZZKDtuerCE1YABQgzVQ== 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=o6bppb7PG9jTqTWwPpeduV/h3tI1WB3Xfm3JPLaCF4I=; b=VXWEugRzkul9BEu/JCsK5TKw22MQQ7QQO3lrGyEygL+ZfUlXm14B8qSu1cfZXKAT40R0oel+AtyK3UOzG9tmVEH8gJTi3PqHBGz7o2SNDKTyE6vsWvAbmNGK2rmMOmrPvFIoZQu7bGpa+XqX4fZ/IZOAcFTdMIFGYS/5L3GbvSjepCMIAKF6ePw2sMY/8SYjhnU7JOnFXPaF05sUU/kFzQoaDiclB7EA3l6dckYbN8W0rhGXPaZVvI1+KMopWBKzfbgJnTF/6KzcCOqcxRWA3nHmYqT/o4XXihgUMalVTWhGPr9Tu5DWZSrauc/m5EMF03EkiYybyccQDPLxLn2UkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o6bppb7PG9jTqTWwPpeduV/h3tI1WB3Xfm3JPLaCF4I=; b=KoxyghfuL9IBxuax+d1qTqb9Ku/r+W0aktZDnSPvdUP9c5K/6a1jA30wQY81ozRQ8iaAnf3Wo8/GhCtPbL9cM2gYEx2QgUo22xkLe0LMvTnbFI+YM1x4sICWwiTTwiSbZ9ctaNAAgmY+CyhXnekLbk+qSgECFrvlGZJ0+ambVp4= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.188.154) by AM4PR05MB3252.eurprd05.prod.outlook.com (10.171.186.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Mon, 21 Oct 2019 05:01:04 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::edab:529f:d14e:d3b]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::edab:529f:d14e:d3b%7]) with mapi id 15.20.2347.028; Mon, 21 Oct 2019 05:01:04 +0000 From: Slava Ovsiienko To: Jack Min , Shahaf Shuler CC: "dev@dpdk.org" , "stable@dpdk.org" , Zengmo Gao Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: fix segfault when create hash rxq of drop Thread-Index: AQHVhNignDX+RpelA0mvNLig3Wy3GKdkjwwQ Date: Mon, 21 Oct 2019 05:01:04 +0000 Message-ID: References: <5457ba5f9334191a03696e630fde2ddbe31ad879.1571305289.git.jackmin@mellanox.com> In-Reply-To: <5457ba5f9334191a03696e630fde2ddbe31ad879.1571305289.git.jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a6c31059-d500-4eb6-e099-08d755e3ad1a x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: AM4PR05MB3252:|AM4PR05MB3252: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-forefront-prvs: 0197AFBD92 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(376002)(136003)(396003)(346002)(366004)(189003)(199004)(13464003)(14454004)(2906002)(478600001)(71200400001)(71190400001)(33656002)(25786009)(8936002)(3846002)(6116002)(66066001)(6246003)(86362001)(6636002)(9686003)(229853002)(54906003)(4326008)(55016002)(316002)(7736002)(74316002)(5660300002)(486006)(7696005)(6506007)(66446008)(52536014)(305945005)(14444005)(186003)(76116006)(256004)(99286004)(53546011)(102836004)(26005)(76176011)(11346002)(81166006)(476003)(66946007)(446003)(66476007)(66556008)(64756008)(81156014)(110136005)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3252; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zZdersJHAMBnanVouOj56qmr6ygC67UnZyBRy+TNJ/Y5C02QgpeB3IpIzUnypGvFQY1DEaERkni4UAJo6LAVm8+1u2KUacOm/sEvt3h9NaeBGTIvHLyvG4sGFZbC60Y+f5j8dAvUoYrZo5pFs8+bMKN60qOj6+awQvWB5l0RM1IaWH5uF4KjBrAG5TC/cWFCOts5PK7+o+9MH06wUvaMHt7mDWZolWilnIYR+bWhYkjlSdvKjyIZv687B2E/rys48oOPFSpOuv0ypYJTAB0C69iqbVZyUQXi2Nz8TTgwaFMujx4pXViF6s4BR/oq+1b13uINe4F9cuQOn5EUJUuW1HF2XzS+j/xH39oXX3H6/vECi26fX441ob/SGaTWpT7hcI2G0VlXfMw+8zRoNf68YpCoCL/VFrthJB2d/XYi6fw= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6c31059-d500-4eb6-e099-08d755e3ad1a X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2019 05:01:04.5432 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mBJyS0mXURqKa2Qje9pLBnYYIR3wTNCXleLZ+aX1o012K6Rxk1Eog2Ug9UtbsSHuGvYtPE5PhtBqVAceptad/zzNf0nsIeiwo9ITML9gkzQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3252 Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/mlx5: fix segfault when create hash rxq of drop X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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" > -----Original Message----- > From: dev On Behalf Of Xiaoyu Min > Sent: Thursday, October 17, 2019 13:50 > To: Shahaf Shuler ; Yongseok Koh > > Cc: dev@dpdk.org; stable@dpdk.org; Zengmo Gao > Subject: [dpdk-dev] [PATCH] net/mlx5: fix segfault when create hash rxq o= f > drop >=20 > When to create hrxq for the drop, it could fail on creating qp and goto t= he > error handle which will release created ind_table by calling drop release > function, which takes rte_ethdev as the only parameter and uses the > priv->drop_queue.hrxq as input to release. >=20 > Unfortunately, at this point, the hrxq is not allocated and > priv->drop_queue.hrxq is still NULL, which leads to a segfault. >=20 > This patch fixes the above by allocating the hrxq at first place and when= the > error happens, hrxq is released as the last one. >=20 > This patch also release other allocated resources by the correct order, w= hich > is missing previously. >=20 > Fixes: 78be885295b8 ("net/mlx5: handle drop queues as regular queues") > Cc: stable@dpdk.org >=20 > Reported-by: Zengmo Gao > Signed-off-by: Xiaoyu Min Acked-by: Viacheslav Ovsiienko > --- > drivers/net/mlx5/mlx5_rxq.c | 38 +++++++++++++++++++++++-------------- > 1 file changed, 24 insertions(+), 14 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c in= dex > 0db065a22c..f0ab8438d3 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -2536,17 +2536,27 @@ struct mlx5_hrxq * mlx5_hrxq_drop_new(struct > rte_eth_dev *dev) { > struct mlx5_priv *priv =3D dev->data->dev_private; > - struct mlx5_ind_table_obj *ind_tbl; > - struct ibv_qp *qp; > - struct mlx5_hrxq *hrxq; > + struct mlx5_ind_table_obj *ind_tbl =3D NULL; > + struct ibv_qp *qp =3D NULL; > + struct mlx5_hrxq *hrxq =3D NULL; >=20 > if (priv->drop_queue.hrxq) { > rte_atomic32_inc(&priv->drop_queue.hrxq->refcnt); > return priv->drop_queue.hrxq; > } > + hrxq =3D rte_calloc(__func__, 1, sizeof(*hrxq), 0); > + if (!hrxq) { > + DRV_LOG(WARNING, > + "port %u cannot allocate memory for drop queue", > + dev->data->port_id); > + rte_errno =3D ENOMEM; > + goto error; > + } > + priv->drop_queue.hrxq =3D hrxq; > ind_tbl =3D mlx5_ind_table_obj_drop_new(dev); > if (!ind_tbl) > - return NULL; > + goto error; > + hrxq->ind_table =3D ind_tbl; > qp =3D mlx5_glue->create_qp_ex(priv->sh->ctx, > &(struct ibv_qp_init_attr_ex){ > .qp_type =3D IBV_QPT_RAW_PACKET, > @@ -2570,15 +2580,6 @@ mlx5_hrxq_drop_new(struct rte_eth_dev *dev) > rte_errno =3D errno; > goto error; > } > - hrxq =3D rte_calloc(__func__, 1, sizeof(*hrxq), 0); > - if (!hrxq) { > - DRV_LOG(WARNING, > - "port %u cannot allocate memory for drop queue", > - dev->data->port_id); > - rte_errno =3D ENOMEM; > - goto error; > - } > - hrxq->ind_table =3D ind_tbl; > hrxq->qp =3D qp; > #ifdef HAVE_IBV_FLOW_DV_SUPPORT > hrxq->action =3D mlx5_glue- > >dv_create_flow_action_dest_ibv_qp(hrxq->qp); > @@ -2587,12 +2588,21 @@ mlx5_hrxq_drop_new(struct rte_eth_dev *dev) > goto error; > } > #endif > - priv->drop_queue.hrxq =3D hrxq; > rte_atomic32_set(&hrxq->refcnt, 1); > return hrxq; > error: > +#ifdef HAVE_IBV_FLOW_DV_SUPPORT > + if (hrxq && hrxq->action) > + mlx5_glue->destroy_flow_action(hrxq->action); > +#endif > + if (qp) > + claim_zero(mlx5_glue->destroy_qp(hrxq->qp)); > if (ind_tbl) > mlx5_ind_table_obj_drop_release(dev); > + if (hrxq) { > + priv->drop_queue.hrxq =3D NULL; > + rte_free(hrxq); > + } > return NULL; > } >=20 > -- > 2.23.0