[dpdk-stable] [dpdk-dev] [PATCH v2] ethdev: avoid usage of uninit device info in bad port case
Andrew Rybchenko
arybchenko at solarflare.com
Tue Jul 23 15:34:30 CEST 2019
On 7/23/19 4:14 PM, Thomas Monjalon wrote:
> 23/07/2019 14:11, Andrew Rybchenko:
>> rte_eth_dev_info_get() returns void and caller does know if the function
>> does its job or not. Changing of the return value to int would be
>> API/ABI breakage which requires deprecation process and cannot be
>> backported to stable branches. For now, make sure that device info is
>> initialized even in the case of invalid port ID.
>>
>> Fixes: a30268e9a2d0 ("ethdev: reset whole dev info structure before filling")
>> Cc: stable at dpdk.org
>>
>> Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
>> ---
>> --- a/lib/librte_ethdev/rte_ethdev.c
>> +++ b/lib/librte_ethdev/rte_ethdev.c
>> + /*
>> + * Init dev_info before port_id check since caller does not have
>> + * return status and does not know if get is successful or not.
>> + */
>> + memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
> If someone was using a canary to detect failure, it will be resetted.
I've not thought about such ways to check. I would expected check
for not NULL device or driver_name. It is not defined behaviour of
the function to not touch dev_info in the case of bad port ID.
> Why is it urgent to have this workaround?
Nothing really urgent, but I still think that it is a right fix to be
applied and backported to stable branches.
I really met calls with invalid port ID and it took some time
to understand where uninitialized data come from.
> Can we wait one more release for the definitive fix with error code?
No strong opinion, but definitive fix will not be backported.
>> +
>> RTE_ETH_VALID_PORTID_OR_RET(port_id);
>> dev = &rte_eth_devices[port_id];
>>
>> - memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
>> dev_info->rx_desc_lim = lim;
>> dev_info->tx_desc_lim = lim;
>> dev_info->device = dev->device;
>>
More information about the stable
mailing list