[PATCH 2/2] ethdev: cleanup shared data with the last port

David Marchand david.marchand at redhat.com
Fri Aug 18 13:36:10 CEST 2023


On Fri, Aug 18, 2023 at 11:13 AM David Marchand
<david.marchand at redhat.com> wrote:
> @@ -253,6 +255,10 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
>                 rte_free(eth_dev->data->dev_private);
>                 pthread_mutex_destroy(&eth_dev->data->flow_ops_mutex);
>                 memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));

At device cleanup stage (rte_eal_cleanup -> bus -> device),
eth_dev_allocated() may still be called and use a leftover reference
to (freed) data.
So here, we need to reset it to NULL (caught by ASan with test-null.sh
in the CI).

This will be in v2.


> +
> +               eth_dev_shared_data->allocated_count--;
> +               if (eth_dev_shared_data->allocated_count == 0)
> +                       eth_dev_shared_data_release();
>         }
>
>         rte_spinlock_unlock(rte_mcfg_ethdev_get_lock());


-- 
David Marchand



More information about the dev mailing list