[dpdk-dev,v3,1/2] net/mlx5: fix double free on error handling

Message ID 1525770687-22980-1-git-send-email-rasland@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Raslan Darawsheh May 8, 2018, 9:11 a.m. UTC
  When attr_ctx is NULL it will attempt to free the list of devices twice.
Avoid double freeing the list by directly going to error handling.

Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Cc: stable@dpdk.org

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

---
v2 changes:
 Better handle for switch statement.
 Reword the commit log.

v3 changes:
 Reword the commit log title.
 add more figures to the Fixes commit
---
---
 drivers/net/mlx5/mlx5.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Yongseok Koh May 8, 2018, 7:08 p.m. UTC | #1
> On May 8, 2018, at 2:11 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:
> 
> When attr_ctx is NULL it will attempt to free the list of devices twice.
> Avoid double freeing the list by directly going to error handling.
> 
> Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

Acked-by: Yongseok Koh <yskoh@mellanox.com>
 
Thanks
  
Shahaf Shuler May 9, 2018, 9:51 a.m. UTC | #2
Tuesday, May 8, 2018 10:09 PM, Yongseok Koh:
> Subject: Re: [PATCH v3 1/2] net/mlx5: fix double free on error handling
> 
> 
> > On May 8, 2018, at 2:11 AM, Raslan Darawsheh <rasland@mellanox.com>
> wrote:
> >
> > When attr_ctx is NULL it will attempt to free the list of devices twice.
> > Avoid double freeing the list by directly going to error handling.
> >
> > Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4
> adapters")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> Acked-by: Yongseok Koh <yskoh@mellanox.com>

Series applied to next-net-mlx, thanks. 

> 
> Thanks
  

Patch

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5190b9f..3831e3d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -690,18 +690,18 @@  mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		break;
 	}
 	if (attr_ctx == NULL) {
-		mlx5_glue->free_device_list(list);
 		switch (err) {
 		case 0:
 			DRV_LOG(ERR,
 				"cannot access device, is mlx5_ib loaded?");
 			err = ENODEV;
-			goto error;
+			break;
 		case EINVAL:
 			DRV_LOG(ERR,
 				"cannot use device, are drivers up to date?");
-			goto error;
+			break;
 		}
+		goto error;
 	}
 	ibv_dev = list[i];
 	DRV_LOG(DEBUG, "device opened");