Commit 41aa29a5 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: cls_bpf: fix NULL deref on offload filter removal

Commit 40119211 ("net: sched: refactor block offloads counter
usage") missed the fact that either new prog or old prog may be
NULL.

Fixes: 40119211 ("net: sched: refactor block offloads counter usage")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8101e069
...@@ -162,16 +162,20 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, ...@@ -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.name = obj->bpf_name;
cls_bpf.exts_integrated = obj->exts_integrated; cls_bpf.exts_integrated = obj->exts_integrated;
if (oldprog) if (oldprog && prog)
err = tc_setup_cb_replace(block, tp, TC_SETUP_CLSBPF, &cls_bpf, err = tc_setup_cb_replace(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
skip_sw, &oldprog->gen_flags, skip_sw, &oldprog->gen_flags,
&oldprog->in_hw_count, &oldprog->in_hw_count,
&prog->gen_flags, &prog->in_hw_count, &prog->gen_flags, &prog->in_hw_count,
true); true);
else else if (prog)
err = tc_setup_cb_add(block, tp, TC_SETUP_CLSBPF, &cls_bpf, err = tc_setup_cb_add(block, tp, TC_SETUP_CLSBPF, &cls_bpf,
skip_sw, &prog->gen_flags, skip_sw, &prog->gen_flags,
&prog->in_hw_count, true); &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) { if (prog && err) {
cls_bpf_offload_cmd(tp, oldprog, prog, extack); cls_bpf_offload_cmd(tp, oldprog, prog, extack);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment