From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 5EAFEA05D3 for ; Mon, 20 May 2019 19:41:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C23864F91; Mon, 20 May 2019 19:41:46 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150075.outbound.protection.outlook.com [40.107.15.75]) by dpdk.org (Postfix) with ESMTP id 3D39A152A; Mon, 20 May 2019 19:41:45 +0200 (CEST) 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=fT5inuuj8XvOZdWqbrxMT4d7e72s2tXxS9fNduHGGDI=; b=S4d1fEb5CfOVMWqQX4Rp3E1EHqiwQWqPdIj4kOyM3cdzx4ooeAvMDlPZbxIvLKxBpde/XN/CaQU73NBXAKGImipduSkXb1OTTfWNt+8cWvNye8eTjivUIVBx3xfGyO7sWe5F9HeotIeq+xhKhfizPjtm8j3S1eL4+Yx+dnUkYRM= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.190.15) by AM4PR05MB3233.eurprd05.prod.outlook.com (10.171.188.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.18; Mon, 20 May 2019 17:41:44 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::c9ea:c445:68e5:942]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::c9ea:c445:68e5:942%4]) with mapi id 15.20.1900.020; Mon, 20 May 2019 17:41:44 +0000 From: Ori Kam To: Dekel Peled , Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: fix memory free on queue create error Thread-Index: AQHVDuORXuclP0b6Ak+BCIyTauLTbKZ0SKhA Date: Mon, 20 May 2019 17:41:44 +0000 Message-ID: References: <40248d25f5870fbfd7e6b7df7dd6d5bd26f65559.1558339581.git.dekelp@mellanox.com> In-Reply-To: <40248d25f5870fbfd7e6b7df7dd6d5bd26f65559.1558339581.git.dekelp@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=orika@mellanox.com; x-originating-ip: [185.175.35.255] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 57527629-32bd-42a5-dd24-08d6dd4a6cc9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:AM4PR05MB3233; x-ms-traffictypediagnostic: AM4PR05MB3233: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:218; x-forefront-prvs: 004395A01C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(376002)(136003)(346002)(189003)(199004)(13464003)(86362001)(14444005)(26005)(446003)(186003)(52536014)(256004)(476003)(486006)(11346002)(99286004)(6636002)(33656002)(3846002)(6116002)(2906002)(110136005)(54906003)(102836004)(53546011)(6506007)(76176011)(5660300002)(7696005)(450100002)(53936002)(4326008)(229853002)(6246003)(68736007)(25786009)(66066001)(7736002)(316002)(9686003)(8936002)(8676002)(81156014)(81166006)(305945005)(478600001)(14454004)(74316002)(66476007)(71190400001)(71200400001)(6436002)(76116006)(66556008)(64756008)(55016002)(73956011)(66946007)(66446008)(7756004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3233; H:AM4PR05MB3425.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-message-info: ty73Ew6TJkj0MgrCL6zkL8YB9/jnE8SZlic8Jj152IVuwi5z9xFu1t3PtMOOMIe+zowd+Jf9iTzI9COsS62obRK81vWB0nivrQKqqpGQfnB6MhbqK3qtLyKIXExfL+fx83KHqKRQX52+Cywe3tivC2sBy/L6+tV1S7x/mGTH9WVE7UX95RH5khzHZqdnEA6MuWJayS1N6oZZkVLv8CSj5L5MaEARYpPcJ6lqfOXvgeLLb0+q7/TRoJXlxdPaya7LOAiyly7PpKK5QWwHHz5JzWIV2ToBBsJdWtAA5B71J7PU8+oxxfqz7zvjM5DjfyMLQvzWLrTCh+hOOZtm5+b135amQ2SCU47N1HYoqhVqezYJ0Ar10i6svsS9k4B7kG9SfLQ6ElE5RhmrmvZR8lSI6nY/mqxvWqLllsAActt9iHI= 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: 57527629-32bd-42a5-dd24-08d6dd4a6cc9 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2019 17:41:44.0831 (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-Transport-CrossTenantHeadersStamped: AM4PR05MB3233 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix memory free on queue create error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev On Behalf Of Dekel Peled > Sent: Monday, May 20, 2019 11:07 AM > To: Yongseok Koh ; Shahaf Shuler > > Cc: dev@dpdk.org; Ori Kam ; stable@dpdk.org > Subject: [dpdk-dev] [PATCH] net/mlx5: fix memory free on queue create err= or >=20 > In function mlx5_rxq_ibv_new(), pointer *tmpl allocation is attempted > at the start, but not validated or freed in case of error. > In function mlx5_txq_ibv_new(), pointer *txq_ibv allocation is > attempted at the start, but not freed in case of error. >=20 > This patch adds pointers initialization, validation and freeing. >=20 > Fixes: 09cb5b581762 ("net/mlx5: separate DPDK from verbs Rx queue objects= ") > Fixes: faf2667fe8d5 ("net/mlx5: separate DPDK from verbs Tx queue objects= ") > Cc: stable@dpdk.org >=20 > Signed-off-by: Dekel Peled > --- > drivers/net/mlx5/mlx5_rxq.c | 22 +++++++++++++--------- > drivers/net/mlx5/mlx5_txq.c | 4 +++- > 2 files changed, 16 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index a00cb12..8cd6157 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -776,7 +776,7 @@ struct mlx5_rxq_ibv * > } attr; > unsigned int cqe_n; > unsigned int wqe_n =3D 1 << rxq_data->elts_n; > - struct mlx5_rxq_ibv *tmpl; > + struct mlx5_rxq_ibv *tmpl =3D NULL; > struct mlx5dv_cq cq_info; > struct mlx5dv_rwq rwq; > unsigned int i; > @@ -1017,15 +1017,19 @@ struct mlx5_rxq_ibv * > priv->verbs_alloc_ctx.type =3D MLX5_VERBS_ALLOC_TYPE_NONE; > return tmpl; > error: > - ret =3D rte_errno; /* Save rte_errno before cleanup. */ > - if (tmpl->wq) > - claim_zero(mlx5_glue->destroy_wq(tmpl->wq)); > - if (tmpl->cq) > - claim_zero(mlx5_glue->destroy_cq(tmpl->cq)); > - if (tmpl->channel) > - claim_zero(mlx5_glue->destroy_comp_channel(tmpl- > >channel)); > + if (tmpl) { > + ret =3D rte_errno; /* Save rte_errno before cleanup. */ > + if (tmpl->wq) > + claim_zero(mlx5_glue->destroy_wq(tmpl->wq)); > + if (tmpl->cq) > + claim_zero(mlx5_glue->destroy_cq(tmpl->cq)); > + if (tmpl->channel) > + claim_zero(mlx5_glue->destroy_comp_channel > + (tmpl->channel)); > + rte_free(tmpl); > + rte_errno =3D ret; /* Restore rte_errno. */ > + } > priv->verbs_alloc_ctx.type =3D MLX5_VERBS_ALLOC_TYPE_NONE; > - rte_errno =3D ret; /* Restore rte_errno. */ > return NULL; > } >=20 > diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c > index b281c45..9efbab6 100644 > --- a/drivers/net/mlx5/mlx5_txq.c > +++ b/drivers/net/mlx5/mlx5_txq.c > @@ -401,7 +401,7 @@ struct mlx5_txq_ibv * > struct mlx5_txq_ctrl *txq_ctrl =3D > container_of(txq_data, struct mlx5_txq_ctrl, txq); > struct mlx5_txq_ibv tmpl; > - struct mlx5_txq_ibv *txq_ibv; > + struct mlx5_txq_ibv *txq_ibv =3D NULL; > union { > struct ibv_qp_init_attr_ex init; > struct ibv_cq_init_attr_ex cq; > @@ -586,6 +586,8 @@ struct mlx5_txq_ibv * > claim_zero(mlx5_glue->destroy_cq(tmpl.cq)); > if (tmpl.qp) > claim_zero(mlx5_glue->destroy_qp(tmpl.qp)); > + if (txq_ibv) > + rte_free(txq_ibv); > priv->verbs_alloc_ctx.type =3D MLX5_VERBS_ALLOC_TYPE_NONE; > rte_errno =3D ret; /* Restore rte_errno. */ > return NULL; > -- > 1.8.3.1 Acked-by: Ori Kam Thanks, Ori Kam