diff mbox series

[v2,net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()

Message ID f08ac289-d57f-4a1a-830f-cf9a0563cb9c@moroto.mountain (mailing list archive)
State Accepted
Commit 9145e2249ed68af99fdbbbf6111aaf0e2dfb72d0
Delegated to: Netdev Maintainers
Headers show
Series [v2,net] nexthop: fix uninitialized variable in nla_put_nh_group_stats() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 942 this patch: 942
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 959 this patch: 959
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-23--00-00 (tests: 943)

Commit Message

Dan Carpenter March 21, 2024, 2:42 p.m. UTC
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: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: Set the variable in nh_grp_hw_stats_update() instead of
    nla_put_nh_group_stats().

 net/ipv4/nexthop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jiri Pirko March 21, 2024, 3:35 p.m. UTC | #1
Thu, Mar 21, 2024 at 03:42:18PM CET, dan.carpenter@linaro.org wrote:
>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: 5072ae00aea4 ("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>
Ido Schimmel March 21, 2024, 5:36 p.m. UTC | #2
On Thu, Mar 21, 2024 at 05:42:18PM +0300, Dan Carpenter wrote:
> 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: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>
patchwork-bot+netdevbpf@kernel.org March 23, 2024, 1:10 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 21 Mar 2024 17:42:18 +0300 you wrote:
> 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: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: Set the variable in nh_grp_hw_stats_update() instead of
>     nla_put_nh_group_stats().
> 
> [...]

Here is the summary with links:
  - [v2,net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
    https://git.kernel.org/netdev/net/c/9145e2249ed6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 74928a9d1aa4..535856b0f0ed 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -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)