Subject: Re: [PATCH net-next 7/7] net: nexthop: Expose nexthop group HW stats to user space

From: Jakub Kicinski <[email-masked]>
Date: Tue, 27 Feb 2024 19:39:32 -0800

On Tue, 27 Feb 2024 19:17:32 +0100 Petr Machata wrote:
> +	if (nla_put_u32(skb, NHA_HW_STATS_ENABLE, nhg->hw_stats))
> +		goto nla_put_failure;
> +
> +	if (op_flags & NHA_OP_FLAG_DUMP_HW_STATS &&
> +	    nhg->hw_stats) {
> +		err = nh_grp_hw_stats_update(nh, &hw_stats_used);
> +		if (err)
> +			goto hw_stats_update_fail;
> +
> +		if (nla_put_u32(skb, NHA_HW_STATS_USED, hw_stats_used))
> +			goto nla_put_failure;

Something's off with the jump targets here.
clang detects nest is not initialized and you'll try to cancel it

> +	}
> +
>  	nest = nla_nest_start(skb, NHA_GROUP_STATS);
>  	if (!nest)
>  		return -EMSGSIZE;
>  
>  	for (i = 0; i < nhg->num_nh; i++)
> -		if (nla_put_nh_group_stats_entry(skb, &nhg->nh_entries[i]))
> +		if (nla_put_nh_group_stats_entry(skb, &nhg->nh_entries[i],
> +						 op_flags))
>  			goto nla_put_failure;
>  
>  	nla_nest_end(skb, nest);
>  	return 0;
>  
>  nla_put_failure:
> +	err = -EMSGSIZE;
> +hw_stats_update_fail:
>  	nla_nest_cancel(skb, nest);
> -	return -EMSGSIZE;
> +	return err;
-- 
pw-bot: cr