Skip to content

Commit 115ef44

Browse files
Jun Yangkuba-moo
authored andcommitted
sched: address a potential NULL pointer dereference in the GRED scheduler.
If kzalloc in gred_init returns a NULL pointer, the code follows the error handling path, invoking gred_destroy. This, in turn, calls gred_offload, where memset could receive a NULL pointer as input, potentially leading to a kernel crash. When table->opt is NULL in gred_init(), gred_change_table_def() is not called yet, so it is not necessary to call ->ndo_setup_tc() in gred_offload(). Signed-off-by: Jun Yang <[email protected]> Reviewed-by: Cong Wang <[email protected]> Fixes: f25c051 ("net: sched: gred: dynamically allocate tc_gred_qopt_offload") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e4e832d commit 115ef44

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/sched/sch_gred.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ static void gred_destroy(struct Qdisc *sch)
913913
for (i = 0; i < table->DPs; i++)
914914
gred_destroy_vq(table->tab[i]);
915915

916-
gred_offload(sch, TC_GRED_DESTROY);
916+
if (table->opt)
917+
gred_offload(sch, TC_GRED_DESTROY);
917918
kfree(table->opt);
918919
}
919920

0 commit comments

Comments
 (0)