net: cls_bpf: fix NULL deref on offload filter removal
Commit4011921137
("net: sched: refactor block offloads counter usage") missed the fact that either new prog or old prog may be NULL. Fixes:4011921137
("net: sched: refactor block offloads counter usage") Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8101e06941
commit
41aa29a58b
|
@ -162,16 +162,20 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
|
|||
cls_bpf.name = obj->bpf_name;
|
||||
cls_bpf.exts_integrated = obj->exts_integrated;
|
||||
|
||||
if (oldprog)
|
||||
if (oldprog && prog)
|
||||
err = tc_setup_cb_replace(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
|
||||
skip_sw, &oldprog->gen_flags,
|
||||
&oldprog->in_hw_count,
|
||||
&prog->gen_flags, &prog->in_hw_count,
|
||||
true);
|
||||
else
|
||||
else if (prog)
|
||||
err = tc_setup_cb_add(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
|
||||
skip_sw, &prog->gen_flags,
|
||||
&prog->in_hw_count, true);
|
||||
else
|
||||
err = tc_setup_cb_destroy(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
|
||||
skip_sw, &oldprog->gen_flags,
|
||||
&oldprog->in_hw_count, true);
|
||||
|
||||
if (prog && err) {
|
||||
cls_bpf_offload_cmd(tp, oldprog, prog, extack);
|
||||
|
|
Loading…
Reference in New Issue