From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0060.outbound.protection.outlook.com [104.47.0.60]) by dpdk.org (Postfix) with ESMTP id 78BDF2C6D; Mon, 7 May 2018 19:14:25 +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; bh=PuY0Zz9Xv4eec767+Q4SYF2WsHjigYxweF5MW2uVQrQ=; b=IzUTxVi0p17HfwgABaX+60J/qEiZxwkYLdhuZd+IIs3OUyi8qMXoHkTU6ShLEaEExIDEK8if7uuHgi4bP5Tbg1UAeKCPCKxbpAT7F0fcW3ubu/qXUh/9Ej/5tFl+ayi/y1+qhc10EFFWMg7t8D6VoTS3GZAPglsi996W23JQc1E= Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com (10.167.195.147) by VI1PR0501MB2526.eurprd05.prod.outlook.com (10.168.136.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.17; Mon, 7 May 2018 17:14:22 +0000 Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::11b2:1e2d:709c:695d]) by VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::11b2:1e2d:709c:695d%13]) with mapi id 15.20.0735.019; Mon, 7 May 2018 17:14:22 +0000 From: Yongseok Koh To: Raslan Darawsheh CC: Shahaf Shuler , "dev@dpdk.org" , Thomas Monjalon , Ophir Munk , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] net/mlx5: fix multiple free issue when attr ctx is NULL Thread-Index: AQHT5f2k3J/xAADMC0Ch0UDN00Sx3KQkgbEA Date: Mon, 7 May 2018 17:14:22 +0000 Message-ID: <2027735E-4EF9-4ED1-AC07-7E2AF59263FC@mellanox.com> References: <1525695534-15072-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1525695534-15072-1-git-send-email-rasland@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; VI1PR0501MB2526; 7:cSjewKK1gcgamomBR1hRWd/Sh8f5Wg6NsYkgMEWg8DY2TucXwkT85cZjnqAM3Rve0Y9yvBC5P9ZButw+hD3KbxXEZFqk0CF6i57UToFpozsNBvU/B3Tws6xF7WNct9/pmPnCUWFGoaJ6ncSyezA4DOpNa3KhmyBB/Qon2MQqhSEcbBEWEurmIp27Tnmd5LT7PenNVKRp6CBABDLzfwvxjly6scsP0qM9Ifs7pUChcAEsIqdVQ3SRjDPChEmAQ67j x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2526; x-ms-traffictypediagnostic: VI1PR0501MB2526: 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)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0501MB2526; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2526; x-forefront-prvs: 066517B35B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(39380400002)(396003)(346002)(376002)(199004)(189003)(486006)(37006003)(33656002)(68736007)(4326008)(106356001)(66066001)(6636002)(316002)(476003)(3660700001)(86362001)(25786009)(3280700002)(54906003)(105586002)(82746002)(2616005)(36756003)(6116002)(3846002)(5250100002)(2900100001)(97736004)(6512007)(6486002)(6436002)(478600001)(59450400001)(229853002)(5660300001)(7736002)(102836004)(8936002)(81166006)(76176011)(305945005)(6862004)(11346002)(446003)(14454004)(6246003)(99286004)(83716003)(53546011)(26005)(2906002)(81156014)(6506007)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2526; H:VI1PR0501MB2045.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nLev627vz1/qZV/LomH2fekwA/BNJISE6PJRMmbCXxWfH/aSrsmZeTf9USwqyGmU3eHQJGBb4baA0u+80wBmwfVhLSnAfthAN6bcam8hrKqm+AtzZutFu/vVFJanvY3KmSfenj0opuDd0Q+cIa5BggeBHj83BYfUeHoOB178IlNQ1Jv9DauXpfL7C1/s1196 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 376668f5-b911-42b9-facd-08d5b43dfa07 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 376668f5-b911-42b9-facd-08d5b43dfa07 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 May 2018 17:14:22.2218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2526 Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx5: fix multiple free issue when attr ctx is NULL 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: , X-List-Received-Date: Mon, 07 May 2018 17:14:25 -0000 > On May 7, 2018, at 5:18 AM, Raslan Darawsheh wrote= : Please don't use PMD/code specific words in the title. I suggest: net/mlx5: fix double free on error handling > When attr_ctx is NULL it will attempt to free the list of devices twice. > So, changing it to be freed in error handling only. >=20 > Fixes: 771fa900 ("mlx5: introduce new driver for Mellanox ConnectX-4 adap= ters") Prefer to put 12 figures? > Cc: stable@dpdk.org New line here. > Signed-off-by: Raslan Darawsheh > --- > drivers/net/mlx5/mlx5.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c > index 5190b9f..d34076b 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -690,7 +690,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_u= nused, > break; > } > if (attr_ctx =3D=3D NULL) { > - mlx5_glue->free_device_list(list); > switch (err) { > case 0: > DRV_LOG(ERR, > @@ -701,6 +700,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_u= nused, > DRV_LOG(ERR, > "cannot use device, are drivers up to date?"); > goto error; > + default: > + goto error; > } > } > ibv_dev =3D list[i]; > --=20 Nice catch! Looks the goto lines are redundant. How about this instead? diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 5190b9fcd..270f59b27 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -690,18 +690,16 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_u= nused, break; } if (attr_ctx =3D=3D NULL) { - mlx5_glue->free_device_list(list); switch (err) { case 0: DRV_LOG(ERR, "cannot access device, is mlx5_ib loaded?")= ; err =3D ENODEV; - goto error; case EINVAL: DRV_LOG(ERR, "cannot use device, are drivers up to date?= "); - goto error; } + goto error; } ibv_dev =3D list[i]; DRV_LOG(DEBUG, "device opened"); Thanks, Yongseok