[v2] ethdev: fix check of rx configure
Checks
Commit Message
From: Yunjian Wang <wangyunjian@huawei.com>
Coverity flags that 'rx_conf' variable is used before
it's checked for NULL. This patch fixes this issue.
Coverity issue: 363570
Fixes: 4ff702b5dfa9 ("ethdev: introduce Rx buffer split")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2:
fix code styles suggested by Ferruh Yigit
---
lib/librte_ethdev/rte_ethdev.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Comments
On 11/4/2020 1:24 AM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> Coverity flags that 'rx_conf' variable is used before
> it's checked for NULL. This patch fixes this issue.
>
> Coverity issue: 363570
> Fixes: 4ff702b5dfa9 ("ethdev: introduce Rx buffer split")
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
On 11/4/2020 11:11 AM, Ferruh Yigit wrote:
> On 11/4/2020 1:24 AM, wangyunjian wrote:
>> From: Yunjian Wang <wangyunjian@huawei.com>
>>
>> Coverity flags that 'rx_conf' variable is used before
>> it's checked for NULL. This patch fixes this issue.
>>
>> Coverity issue: 363570
>> Fixes: 4ff702b5dfa9 ("ethdev: introduce Rx buffer split")
>>
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
Applied to dpdk-next-net/main, thanks.
@@ -1978,9 +1978,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
return -EINVAL;
}
} else {
- const struct rte_eth_rxseg_split *rx_seg =
- (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
- uint16_t n_seg = rx_conf->rx_nseg;
+ const struct rte_eth_rxseg_split *rx_seg;
+ uint16_t n_seg;
/* Extended multi-segment configuration check. */
if (rx_conf == NULL || rx_conf->rx_seg == NULL || rx_conf->rx_nseg == 0) {
@@ -1988,6 +1987,10 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
"Memory pool is null and no extended configuration provided\n");
return -EINVAL;
}
+
+ rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
+ n_seg = rx_conf->rx_nseg;
+
if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
&mbp_buf_size,