netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
@ 2024-03-16  9:46 Dan Carpenter
  2024-03-16 16:29 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2024-03-16  9:46 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Petr Machata, Kees Cook, netdev, linux-kernel,
	kernel-janitors

The nh_grp_hw_stats_update() function doesn't always set "hw_stats_used"
so it could be used without being initialized.  Set it to false.

Fixes: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 net/ipv4/nexthop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 74928a9d1aa4..c25bfdf4e25f 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -824,8 +824,8 @@ static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh,
 				  u32 op_flags)
 {
 	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
+	bool hw_stats_used = false;
 	struct nlattr *nest;
-	bool hw_stats_used;
 	int err;
 	int i;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
  2024-03-16  9:46 [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats() Dan Carpenter
@ 2024-03-16 16:29 ` David Ahern
  2024-03-17  7:56 ` Ido Schimmel
  2024-03-18  8:02 ` Jiri Pirko
  2 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2024-03-16 16:29 UTC (permalink / raw)
  To: Dan Carpenter, Ido Schimmel
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Petr Machata, Kees Cook, netdev, linux-kernel, kernel-janitors

On 3/16/24 3:46 AM, Dan Carpenter wrote:
> The nh_grp_hw_stats_update() function doesn't always set "hw_stats_used"
> so it could be used without being initialized.  Set it to false.
> 
> Fixes: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  net/ipv4/nexthop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 74928a9d1aa4..c25bfdf4e25f 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
> @@ -824,8 +824,8 @@ static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh,
>  				  u32 op_flags)
>  {
>  	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
> +	bool hw_stats_used = false;
>  	struct nlattr *nest;
> -	bool hw_stats_used;
>  	int err;
>  	int i;
>  

Reviewed-by: David Ahern <dsahern@kernel.org>

The flag could be moved under
	`if (op_flags & NHA_OP_FLAG_DUMP_HW_STATS ...`
as well.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
  2024-03-16  9:46 [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats() Dan Carpenter
  2024-03-16 16:29 ` David Ahern
@ 2024-03-17  7:56 ` Ido Schimmel
  2024-03-18  8:02 ` Jiri Pirko
  2 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2024-03-17  7:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Petr Machata, Kees Cook, netdev, linux-kernel,
	kernel-janitors

On Sat, Mar 16, 2024 at 12:46:03PM +0300, Dan Carpenter wrote:
> The nh_grp_hw_stats_update() function doesn't always set "hw_stats_used"
> so it could be used without being initialized.  Set it to false.
> 
> 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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
  2024-03-16  9:46 [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats() Dan Carpenter
  2024-03-16 16:29 ` David Ahern
  2024-03-17  7:56 ` Ido Schimmel
@ 2024-03-18  8:02 ` Jiri Pirko
  2024-03-18  8:11   ` Dan Carpenter
  2 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2024-03-18  8:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ido Schimmel, David Ahern, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Petr Machata, Kees Cook, netdev,
	linux-kernel, kernel-janitors

Sat, Mar 16, 2024 at 10:46:03AM CET, dan.carpenter@linaro.org wrote:
>The nh_grp_hw_stats_update() function doesn't always set "hw_stats_used"
>so it could be used without being initialized.  Set it to false.
>
>Fixes: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
>Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>---
> net/ipv4/nexthop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
>index 74928a9d1aa4..c25bfdf4e25f 100644
>--- a/net/ipv4/nexthop.c
>+++ b/net/ipv4/nexthop.c
>@@ -824,8 +824,8 @@ static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh,
> 				  u32 op_flags)
> {
> 	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
>+	bool hw_stats_used = false;
> 	struct nlattr *nest;
>-	bool hw_stats_used;


Probably better to set this in one place and have:
       if (nexthop_notifiers_is_empty(net)) {
	       *hw_stats_used = false;
               return 0;
       }
in nh_grp_hw_stats_update().




> 	int err;
> 	int i;
> 
>-- 
>2.43.0
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats()
  2024-03-18  8:02 ` Jiri Pirko
@ 2024-03-18  8:11   ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2024-03-18  8:11 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Ido Schimmel, David Ahern, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Petr Machata, Kees Cook, netdev,
	linux-kernel, kernel-janitors

On Mon, Mar 18, 2024 at 09:02:54AM +0100, Jiri Pirko wrote:
> Sat, Mar 16, 2024 at 10:46:03AM CET, dan.carpenter@linaro.org wrote:
> >The nh_grp_hw_stats_update() function doesn't always set "hw_stats_used"
> >so it could be used without being initialized.  Set it to false.
> >
> >Fixes: 5072ae00aea4 ("net: nexthop: Expose nexthop group HW stats to user space")
> >Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> >---
> > net/ipv4/nexthop.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> >index 74928a9d1aa4..c25bfdf4e25f 100644
> >--- a/net/ipv4/nexthop.c
> >+++ b/net/ipv4/nexthop.c
> >@@ -824,8 +824,8 @@ static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh,
> > 				  u32 op_flags)
> > {
> > 	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
> >+	bool hw_stats_used = false;
> > 	struct nlattr *nest;
> >-	bool hw_stats_used;
> 
> 
> Probably better to set this in one place and have:
>        if (nexthop_notifiers_is_empty(net)) {
> 	       *hw_stats_used = false;
>                return 0;
>        }
> in nh_grp_hw_stats_update().
> 

Sure.  Will do.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-18  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-16  9:46 [PATCH net] nexthop: fix uninitialized variable in nla_put_nh_group_stats() Dan Carpenter
2024-03-16 16:29 ` David Ahern
2024-03-17  7:56 ` Ido Schimmel
2024-03-18  8:02 ` Jiri Pirko
2024-03-18  8:11   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).