From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70089.outbound.protection.outlook.com [40.107.7.89]) by dpdk.org (Postfix) with ESMTP id 159E82674 for ; Wed, 15 Aug 2018 19:27:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4bjCDLXKbzw6fC2TDh0cBy+FUqXNlIg+jCkZQioWvN8=; b=wjWtnTIJ0BNZiM2ThGJENvkhvwE9aD4jWG9k1ioeFeadMvp0y+ZNMx6fcAFHDCNjvxRQjUvdAsitS6liucwKVk+6IZA8zSPOL5XiKB7IzjZOa4BtLhFDFBk+yFX6YEgWvI2iEdOx1Lw+rboRtAgTi0QjEO3jxr0UzI9ag/BmOfc= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4043.eurprd05.prod.outlook.com (52.134.72.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.25; Wed, 15 Aug 2018 17:27:28 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::112:180c:634a:c61c]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::112:180c:634a:c61c%2]) with mapi id 15.20.1017.022; Wed, 15 Aug 2018 17:27:28 +0000 From: Yongseok Koh To: Mordechay Haimovsky CC: Adrien Mazarguil , "stable@dpdk.org" Thread-Topic: [PATCH] net/mlx4: fix minor resource leak during init Thread-Index: AQHUNLoDgUxBy+ZQU0GlcPNrzsbPVaTBEQWA Date: Wed, 15 Aug 2018 17:27:28 +0000 Message-ID: References: <1534352643-13073-1-git-send-email-motih@mellanox.com> In-Reply-To: <1534352643-13073-1-git-send-email-motih@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=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4043; 6:zcsRYksEslh446fKeo6p7dthq2bOfqUPTUgOsnEGwq+mkVTdFLgb6N2tmbdWFfLothnhhQHTrsldoGXfHb8JXZKE9chWSrWDZLh4hnbM9et0gezEtlLgmMLctxHeLs4fQ65b3qY0jBh/Wo9QhrPMem0p+BVM1Ko8RQLXlFyvdsjspOBy945usRhQXYPhoAxX8rQQGgQaTM2MOkYbhdHQK/6hMutL8wyPUTk23DhIt7Q3VHWSz4pSsZyowf/c+crTgK5pEoH7OP9dAw3Vj3nXzFLy7Pn9zCyVLh7VPGqwpobqiLqCRUNDYF5shMR/CW7cjX/Dli16fRQzQ7g9zeGYEwNL3pKqvrSYTuB87/VbA+mvDrzBt6/fF7iXnKlvHY7opzhE+CkU7xZZ5UxEXTyNcz6nJb3kSOBSfg+ry6p6lWHARwzOkIi6bUmk5xpM6az8/b4m5UCRpA60sjmApOg6gw==; 5:kgaU8bDm3+6Y3sP/Nw97nxbGQK5hgxfPSXgcQ9ed/1Rr7FRL0XtG3jhCikKY4385Mjg2VM00s+Z8PYLP2t/CizB+gas1jDI/QCBZXePEXqA4smRDne+AtyWgIJZNehtobrGCqUeft+rjHuI2zbN5+qcz/pgsthMTYRCDiHhL0iY=; 7:+oykC62H/mXDaxZpzn4cqHUEwWnWHfpcfuqdmK5CTywpGcoXS1bGzQsmQnLzgY8yTyou4xqPKeul2i8+dHEhfNWrNUEUVieNgfq5JjZQ9bCX9z5uHc7XtHY3EiYIYbuBM/fPxbxD/YlIt2GehMkOdnZeNlT1zFkX65YwwCC6+uAlKIC57Y4fhStmRsZ4qv7cIiVkEkS2ZLlmes2Xva3fjNIbOXPzdFbnQngBky4JHfng6hoHLk/vI1E1AvgXasVn x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 3053bcd8-347a-4d2b-18e1-08d602d46017 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4043; x-ms-traffictypediagnostic: DB3PR0502MB4043: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301033)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:DB3PR0502MB4043; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4043; x-forefront-prvs: 07658B8EA3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(316002)(102836004)(54906003)(99286004)(446003)(476003)(11346002)(53546011)(6506007)(14444005)(256004)(26005)(229853002)(305945005)(2900100001)(7736002)(2616005)(76176011)(82746002)(5660300001)(37006003)(6636002)(36756003)(53936002)(6862004)(25786009)(4326008)(6512007)(486006)(6436002)(97736004)(6246003)(6486002)(106356001)(2906002)(14454004)(66066001)(5250100002)(68736007)(478600001)(105586002)(83716003)(81166006)(81156014)(86362001)(8676002)(8936002)(33656002)(6116002)(3846002)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4043; H:DB3PR0502MB3980.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-microsoft-antispam-message-info: JzCDEMNvivxApV0b/9mVh2bOqgXKAGdqp4P3KcHGqUqcx7ELrWKSy/O/f4rDDTwBzVl64RsLSz6q6gthjEJE9yYURy1ItkA2DGDFTc6nJ/vu5l1SjMf3IMRN7o5MYlYZLzon/IIP8+cS3C2sdIKq814pCv7o3ZNr8i4MWZu3W3dphDrbn5Nfr6s/8afpxUZxG8yZOPygt75cSoC2oP3Tt0tHYLLmejh1tXPTlwHyGCp4VRxZ34z++gdHGqKTxt7dAmG2mVDYQZpwfcueXB1fd+RbAQITFKaI8HWmE+SeknEzcEumubpsDrkEVddbqk3YouyhRbxt3gGeCgW8t5EYz8+3ctGwGZHPnFFkNoJ9KzY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3053bcd8-347a-4d2b-18e1-08d602d46017 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2018 17:27:28.6801 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4043 Subject: Re: [dpdk-stable] [PATCH] net/mlx4: fix minor resource leak during init 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: , X-List-Received-Date: Wed, 15 Aug 2018 17:27:30 -0000 > On Aug 15, 2018, at 10:04 AM, Mordechay Haimovsky wr= ote: >=20 > From: Adrien Mazarguil >=20 > Temporary IB device context and list are not freed in case of a successfu= l > initialization of the device. >=20 > This issue is caused by the two following commits, the first of which > causes initialization to return early, while the second one goes a bit > overboard while switching to negative errno values; an internal variable > (err) is needed to tell success from failure at the end of the function > since rte_errno is not reliable enough. >=20 > Fixes: f2318196c71a ("net/mlx4: remove limitation on number of instances"= ) > Fixes: 9d14b27308a0 ("net/mlx4: standardize on negative errno values") > Cc: stable@dpdk.org >=20 > Signed-off-by: Adrien Mazarguil > Signed-off-by: Moti Haimovsky > --- > drivers/net/mlx4/mlx4.c | 35 ++++++++++++++++++----------------- > 1 file changed, 18 insertions(+), 17 deletions(-) >=20 > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c > index f5c450d..118edd9 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -494,14 +494,14 @@ struct mlx4_conf { > ibv_dev =3D list[i]; > DEBUG("device opened"); > if (ibv_query_device(attr_ctx, &device_attr)) { > - rte_errno =3D ENODEV; > + err =3D ENODEV; > goto error; > } > INFO("%u port(s) detected", device_attr.phys_port_cnt); > conf.ports.present |=3D (UINT64_C(1) << device_attr.phys_port_cnt) - 1; > if (mlx4_args(pci_dev->device.devargs, &conf)) { > ERROR("failed to process device arguments"); > - rte_errno =3D EINVAL; > + err =3D EINVAL; > goto error; > } > /* Use all ports when none are defined */ > @@ -522,18 +522,18 @@ struct mlx4_conf { > DEBUG("using port %u", port); > ctx =3D ibv_open_device(ibv_dev); > if (ctx =3D=3D NULL) { > - rte_errno =3D ENODEV; > + err =3D ENODEV; > goto port_error; > } > /* Check port status. */ > err =3D ibv_query_port(ctx, port, &port_attr); > if (err) { > - rte_errno =3D err; > - ERROR("port query failed: %s", strerror(rte_errno)); > + err =3D ENODEV; > + ERROR("port query failed: %s", strerror(err)); > goto port_error; > } > if (port_attr.link_layer !=3D IBV_LINK_LAYER_ETHERNET) { > - rte_errno =3D ENOTSUP; > + err =3D ENOTSUP; > ERROR("port %d is not configured in Ethernet mode", > port); > goto port_error; > @@ -543,15 +543,16 @@ struct mlx4_conf { > port, ibv_port_state_str(port_attr.state), > port_attr.state); > /* Make asynchronous FD non-blocking to handle interrupts. */ > - if (mlx4_fd_set_non_blocking(ctx->async_fd) < 0) { > + err =3D mlx4_fd_set_non_blocking(ctx->async_fd); > + if (err) { > ERROR("cannot make asynchronous FD non-blocking: %s", > - strerror(rte_errno)); > + strerror(err)); > goto port_error; > } > /* Allocate protection domain. */ > pd =3D ibv_alloc_pd(ctx); > if (pd =3D=3D NULL) { > - rte_errno =3D ENOMEM; > + err =3D ENOMEM; > ERROR("PD allocation failure"); > goto port_error; > } > @@ -560,7 +561,7 @@ struct mlx4_conf { > sizeof(*priv), > RTE_CACHE_LINE_SIZE); > if (priv =3D=3D NULL) { > - rte_errno =3D ENOMEM; > + err =3D ENOMEM; > ERROR("priv allocation failure"); > goto port_error; > } > @@ -585,9 +586,10 @@ struct mlx4_conf { > device_attr_ex.rss_caps.max_rwq_indirection_table_size; > DEBUG("MAX RSS queues %d", priv->hw_rss_max_qps); > /* Configure the first MAC address by default. */ > - if (mlx4_get_mac(priv, &mac.addr_bytes)) { > + err =3D mlx4_get_mac(priv, &mac.addr_bytes); > + if (err) { > ERROR("cannot get MAC address, is mlx4_en loaded?" > - " (rte_errno: %s)", strerror(rte_errno)); > + " (error: %s)", strerror(err)); > goto port_error; > } > INFO("port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x", Thanks for your volunteer. But, this hunk isn't applied cleanly. Please rebase it on top of the latest stable/17.11. Thanks, Yongseok > @@ -620,8 +622,8 @@ struct mlx4_conf { > eth_dev =3D rte_eth_dev_allocate(name); > } > if (eth_dev =3D=3D NULL) { > + err =3D ENOMEM; > ERROR("can not allocate rte ethdev"); > - rte_errno =3D ENOMEM; > goto port_error; > } > eth_dev->data->dev_private =3D priv; > @@ -666,8 +668,6 @@ struct mlx4_conf { > rte_eth_dev_release_port(eth_dev); > break; > } > - if (i =3D=3D device_attr.phys_port_cnt) > - return 0; > /* > * XXX if something went wrong in the loop above, there is a resource > * leak (ctx, pd, priv, dpdk ethdev) but we can do nothing about it as > @@ -679,8 +679,9 @@ struct mlx4_conf { > claim_zero(ibv_close_device(attr_ctx)); > if (list) > ibv_free_device_list(list); > - assert(rte_errno >=3D 0); > - return -rte_errno; > + if (err) > + rte_errno =3D err; > + return -err; > } >=20 > static const struct rte_pci_id mlx4_pci_id_map[] =3D { > --=20 > 1.8.3.1 >=20