[dpdk-dev] [PATCH v9] ethdev: add sanity checks in control APIs

Ferruh Yigit ferruh.yigit at intel.com
Wed Apr 21 16:17:40 CEST 2021


On 4/21/2021 12:28 PM, Andrew Rybchenko wrote:
> On 4/21/21 5:36 AM, Ferruh Yigit wrote:
>> From: "Min Hu (Connor)" <humin29 at huawei.com>
>>
>> This patch adds more sanity checks in control path APIs.
>>
>> Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input")
>> Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables")
>> Fixes: 0366137722a0 ("ethdev: check for invalid device name")
>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
>> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
>> Fixes: f8244c6399d9 ("ethdev: increase port id range")
>> Cc: stable at dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit at intel.com>
>> Reviewed-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
>> Acked-by: Kevin Traynor <ktraynor at redhat.com>

<...>

>> @@ -3323,6 +3457,21 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
>>   
>>   	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>>   	dev = &rte_eth_devices[port_id];
>> +
>> +	if (ptypes == NULL) {
>> +		RTE_ETHDEV_LOG(ERR,
>> +			"Cannot get ethdev port %u supported packet types to NULL\n",
>> +			port_id);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (num == 0) {
>> +		RTE_ETHDEV_LOG(ERR,
>> +			"Cannot get ethdev port %u supported packet types to array with zero size\n",
>> +			port_id);
>> +		return -EINVAL;
>> +	}
>> +
> 
> The error condition is "ptypes == NULL && num > 0".
> Otherwise, if num == 0 (regardless ptypes) it is just
> a call to get size of required buffer. Same as below.
> 
>>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_get, 0);
>>   	all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev);
>>   
> 

Ack. Thanks for catching these issues.



More information about the dev mailing list