soundwire: stream: fix NULL pointer dereference for multi_link
[platform/kernel/linux-starfive.git] / kernel / bpf / trampoline.c
index 78acf28..e97aeda 100644 (file)
@@ -415,8 +415,8 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut
                goto out;
        }
 
-       /* clear all bits except SHARE_IPMODIFY */
-       tr->flags &= BPF_TRAMP_F_SHARE_IPMODIFY;
+       /* clear all bits except SHARE_IPMODIFY and TAIL_CALL_CTX */
+       tr->flags &= (BPF_TRAMP_F_SHARE_IPMODIFY | BPF_TRAMP_F_TAIL_CALL_CTX);
 
        if (tlinks[BPF_TRAMP_FEXIT].nr_links ||
            tlinks[BPF_TRAMP_MODIFY_RETURN].nr_links) {
@@ -926,13 +926,12 @@ u64 notrace __bpf_prog_enter_sleepable_recur(struct bpf_prog *prog,
        migrate_disable();
        might_fault();
 
+       run_ctx->saved_run_ctx = bpf_set_run_ctx(&run_ctx->run_ctx);
+
        if (unlikely(this_cpu_inc_return(*(prog->active)) != 1)) {
                bpf_prog_inc_misses_counter(prog);
                return 0;
        }
-
-       run_ctx->saved_run_ctx = bpf_set_run_ctx(&run_ctx->run_ctx);
-
        return bpf_prog_start_time();
 }