[PATCH v10 10/14] net/sxe: add xstats function

Stephen Hemminger stephen at networkplumber.org
Mon Jul 21 17:32:37 CEST 2025


On Sat, 19 Jul 2025 17:05:33 +0800
Jie Liu <liujie5 at linkdatatechnology.com> wrote:

> +s32 sxe_eth_stats_get(struct rte_eth_dev *eth_dev,
> +				struct rte_eth_stats *stats)
> +{
> +	struct sxe_adapter *adapter = eth_dev->data->dev_private;
> +	struct sxe_stats_info *stats_info = &adapter->stats_info;
> +	struct sxe_hw *hw = &adapter->hw;
> +	u32 i;
> +	u64 rx_packets = 0;
> +	u64 rx_bytes = 0;
> +	s32 ret = 0;
> +
> +	sxe_hw_stats_get(hw, &stats_info->hw_stats);
> +
> +	if (stats == NULL) {
> +		ret = -EINVAL;
> +		PMD_LOG_ERR(DRV, "input param stats is null.");
> +		goto l_out;
> +	}
> +

This check is bad in two ways:
  1. You already derefenced the pointer stats in previous line.
     Coverity and other static tools will report this as an error.
  2. The only thing that should call sxe_eth_stats_get is from rte_Eth_stats_get
     which already checks for NULL.

      


More information about the dev mailing list