bpf: Replace kvfree with kfree for kzalloc memory
authorQianfeng Rong <rongqianfeng@vivo.com>
Mon, 11 Aug 2025 12:39:49 +0000 (20:39 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 12 Aug 2025 22:55:01 +0000 (15:55 -0700)
The 'backedge' pointer is allocated with kzalloc(), which returns
physically contiguous memory. Using kvfree() to deallocate such
memory is functionally safe but semantically incorrect.

Replace kvfree() with kfree() to avoid unnecessary is_vmalloc_addr()
check in kvfree().

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20250811123949.552885-1-rongqianfeng@vivo.com
kernel/bpf/verifier.c

index 3c2e7f3..3a3982f 100644 (file)
@@ -19553,7 +19553,7 @@ hit:
                                err = err ?: add_scc_backedge(env, &sl->state, backedge);
                                if (err) {
                                        free_verifier_state(&backedge->state, false);
-                                       kvfree(backedge);
+                                       kfree(backedge);
                                        return err;
                                }
                        }