Re: [PATCH net-next v3] net: sched: gred: dynamically allocate tc_gred_qopt_offload

From: Denis Kirjanov
Date: Tue Oct 26 2021 - 07:16:27 EST




10/26/21 1:51 PM, Sebastian Andrzej Siewior пишет:
On 2021-10-26 13:42:24 [+0300], Denis Kirjanov wrote:
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index 72de08ef8335e..1073c76d05c45 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -311,42 +312,43 @@ static void gred_offload(struct Qdisc *sch, enum tc_gred_command command)
{
struct gred_sched *table = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
- struct tc_gred_qopt_offload opt = {
- .command = command,
- .handle = sch->handle,
- .parent = sch->parent,
- };
+ struct tc_gred_qopt_offload *opt = table->opt;
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
return;
+ memset(opt, 0, sizeof(*opt));

It's zeroed in kzalloc()

but it is not limited to a single invocation?

I meant that all fields are set in the function as it was with the stack storage.


Sebastian