Merge tag 'rtc-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux] / net / sched / act_bpf.c
index 9092531..18089c0 100644 (file)
@@ -248,10 +248,14 @@ static int tcf_bpf_init_from_efd(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
 
 static void tcf_bpf_cfg_cleanup(const struct tcf_bpf_cfg *cfg)
 {
-       if (cfg->is_ebpf)
-               bpf_prog_put(cfg->filter);
-       else
-               bpf_prog_destroy(cfg->filter);
+       struct bpf_prog *filter = cfg->filter;
+
+       if (filter) {
+               if (cfg->is_ebpf)
+                       bpf_prog_put(filter);
+               else
+                       bpf_prog_destroy(filter);
+       }
 
        kfree(cfg->bpf_ops);
        kfree(cfg->bpf_name);