[dpdk-dev] [PATCH v1] ethdev: fix multi-process NULL dereference crashes

Thomas Monjalon thomas.monjalon at 6wind.com
Fri Jan 20 19:37:33 CET 2017


2017-01-11 02:42, Remy Horton:
> +* **ethdev: Fixed crash with multi-processing.**
> +
> +  Even though only primary processes should setup PMDs, secondary
> +  processes were also blanket zeroing ethernet device memory. The
> +  result was NULL dereference crashes in multi-process setups.
> +

3 comments here:
- it is in the wrong section (EAL instead of Drivers)
- secondary processes can setup a vdev PMD
- before Yuanhan's patch, even PCI PMD were blanking primary process data


> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -212,7 +212,8 @@ rte_eth_dev_allocate(const char *name)
>  
>  	eth_dev = &rte_eth_devices[port_id];
>  	eth_dev->data = &rte_eth_dev_data[port_id];
> -	memset(eth_dev->data, 0, sizeof(*eth_dev->data));
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +		memset(eth_dev->data, 0, sizeof(*eth_dev->data));
>  	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
>  	eth_dev->data->port_id = port_id;
>  	eth_dev->data->mtu = ETHER_MTU;
> 

I propose this rebase:

-       memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
        eth_dev = eth_dev_get(port_id);
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               memset(eth_dev->data, 0, sizeof(*eth_dev->data));
        snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
        eth_dev->data->port_id = port_id;
        eth_dev->data->mtu = ETHER_MTU;



More information about the dev mailing list