Skip to content

Commit

Permalink
nexthop: fix uninitialized variable in nla_put_nh_group_stats()
Browse files Browse the repository at this point in the history
The "*hw_stats_used" value needs to be set on the success paths to prevent
an uninitialized variable bug in the caller, nla_put_nh_group_stats().

Fixes: 5072ae0 ("net: nexthop: Expose nexthop group HW stats to user space")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/f08ac289-d57f-4a1a-830f-cf9a0563cb9c@moroto.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Dan Carpenter authored and Jakub Kicinski committed Mar 23, 2024
1 parent f6c8f5e commit 9145e22
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,10 @@ static int nh_grp_hw_stats_update(struct nexthop *nh, bool *hw_stats_used)
struct net *net = nh->net;
int err;

if (nexthop_notifiers_is_empty(net))
if (nexthop_notifiers_is_empty(net)) {
*hw_stats_used = false;
return 0;
}

err = nh_notifier_grp_hw_stats_init(&info, nh);
if (err)
Expand Down

0 comments on commit 9145e22

Please sign in to comment.