[PATCH 3/7] v2: Use memset() in jit_ctx_init()

Shahab Vahedi list+bpf at vahedi.org
Tue Apr 30 08:09:33 PDT 2024


From: Shahab Vahedi <shahab at synopsys.com>

---
 arch/arc/net/bpf_jit_core.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/arc/net/bpf_jit_core.c b/arch/arc/net/bpf_jit_core.c
index 79ec0bbf1153..9c0fdd514967 100644
--- a/arch/arc/net/bpf_jit_core.c
+++ b/arch/arc/net/bpf_jit_core.c
@@ -159,6 +159,8 @@ static void jit_dump(const struct jit_context *ctx)
 /* Initialise the context so there's no garbage. */
 static int jit_ctx_init(struct jit_context *ctx, struct bpf_prog *prog)
 {
+	memset(ctx, 0, sizeof(ctx));
+
 	ctx->orig_prog = prog;
 
 	/* If constant blinding was requested but failed, scram. */
@@ -167,25 +169,12 @@ static int jit_ctx_init(struct jit_context *ctx, struct bpf_prog *prog)
 		return PTR_ERR(ctx->prog);
 	ctx->blinded = (ctx->prog == ctx->orig_prog ? false : true);
 
-	ctx->jit.buf            = NULL;
-	ctx->jit.len            = 0;
-	ctx->jit.index          = 0;
-	ctx->bpf_header         = NULL;
-	ctx->bpf2insn           = NULL;
-	ctx->bpf2insn_valid     = false;
-	ctx->jit_data           = NULL;
-	ctx->arc_regs_clobbered = 0;
-	ctx->save_blink         = false;
-	ctx->frame_size         = 0;
-	ctx->epilogue_offset    = 0;
-	ctx->need_extra_pass    = false;
-	ctx->is_extra_pass	= ctx->prog->jited;
-	ctx->user_bpf_prog	= ctx->prog->is_func;
-	ctx->success            = false;
-
 	/* If the verifier doesn't zero-extend, then we have to do it. */
 	ctx->do_zext = !ctx->prog->aux->verifier_zext;
 
+	ctx->is_extra_pass = ctx->prog->jited;
+	ctx->user_bpf_prog = ctx->prog->is_func;
+
 	return 0;
 }
 
-- 
2.35.8




More information about the linux-snps-arc mailing list