[PATCH net-next] net/sched: Remove redundant memset(0) call in reset_policy()

Thorsten Blum posted 1 patch 1 month, 3 weeks ago
net/sched/act_simple.c | 1 -
1 file changed, 1 deletion(-)
[PATCH net-next] net/sched: Remove redundant memset(0) call in reset_policy()
Posted by Thorsten Blum 1 month, 3 weeks ago
The call to nla_strscpy() already zero-pads the tail of the destination
buffer which makes the additional memset(0) call redundant. Remove it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 net/sched/act_simple.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index f3abe0545989..8e69a919b4fe 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -72,7 +72,6 @@ static int reset_policy(struct tc_action *a, const struct nlattr *defdata,
 	d = to_defact(a);
 	spin_lock_bh(&d->tcf_lock);
 	goto_ch = tcf_action_set_ctrlact(a, p->action, goto_ch);
-	memset(d->tcfd_defdata, 0, SIMP_MAX_DATA);
 	nla_strscpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA);
 	spin_unlock_bh(&d->tcf_lock);
 	if (goto_ch)
-- 
2.50.1
Re: [PATCH net-next] net/sched: Remove redundant memset(0) call in reset_policy()
Posted by Joe Damato 1 month, 3 weeks ago
On Mon, Aug 11, 2025 at 06:40:38PM +0200, Thorsten Blum wrote:
> The call to nla_strscpy() already zero-pads the tail of the destination
> buffer which makes the additional memset(0) call redundant. Remove it.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  net/sched/act_simple.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
> index f3abe0545989..8e69a919b4fe 100644
> --- a/net/sched/act_simple.c
> +++ b/net/sched/act_simple.c
> @@ -72,7 +72,6 @@ static int reset_policy(struct tc_action *a, const struct nlattr *defdata,
>  	d = to_defact(a);
>  	spin_lock_bh(&d->tcf_lock);
>  	goto_ch = tcf_action_set_ctrlact(a, p->action, goto_ch);
> -	memset(d->tcfd_defdata, 0, SIMP_MAX_DATA);
>  	nla_strscpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA);
>  	spin_unlock_bh(&d->tcf_lock);
>  	if (goto_ch)

Reviewed-by: Joe Damato <joe@dama.to>