On Sat, 19 Jul 2025 17:05:33 +0800
Jie Liu <liuj...@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.

      

Reply via email to