net/tap: fix device freeing

The error path was calling rte_eth_dev_release_port() function,
which frees eth_dev->data->dev_private, and then tries to free
pmd->intr_handle, which causes the use after free issue.

The free can be moved to before the release function is called.

Fixes: d61138d4f0 ("drivers: remove direct access to interrupt handle")
Cc: stable@dpdk.org

Signed-off-by: Xiangjun Meng <mengxiangjun4@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
Yunjian Wang 2022-06-07 14:50:57 +08:00 committed by Andrew Rybchenko
parent fd819cad0a
commit f2aebfc4e9

View File

@ -2179,8 +2179,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
close(pmd->ioctl_sock);
/* mac_addrs must not be freed alone because part of dev_private */
dev->data->mac_addrs = NULL;
rte_eth_dev_release_port(dev);
rte_intr_instance_free(pmd->intr_handle);
rte_eth_dev_release_port(dev);
error_exit_nodev:
TAP_LOG(ERR, "%s Unable to initialize %s",