mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Markus Elfring" <Markus.Elfring@web.de>, <bpf@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>
Cc: "LKML" <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] bpf: Use common error handling code in bpf_is_state_visited()
Date: Wed, 17 Jun 2026 15:48:03 -0400	[thread overview]
Message-ID: <DJBL1JEE322B.28EZ7GUNTJP99@etsalapatis.com> (raw)
In-Reply-To: <d6622225-c765-4d9f-9501-1021df4687a4@web.de>

On Wed Jun 17, 2026 at 3:30 PM EDT, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 17 Jun 2026 21:15:08 +0200
>
> Use an additional label so that a bit of exception handling can be better
> reused at the end of this function implementation.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>

Can you resend with [PATCH bpf-next] in the title? Right now it's not
celar which tree this is targeting so Patchwork is treating this as
a netdev patch.

> ---
>  kernel/bpf/states.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/bpf/states.c b/kernel/bpf/states.c
> index 5945956a7573..09f87e2bb1e6 100644
> --- a/kernel/bpf/states.c
> +++ b/kernel/bpf/states.c
> @@ -1566,21 +1566,16 @@ int bpf_is_state_visited(struct bpf_verifier_env *env, int insn_idx)
>  	/* add new state to the head of linked list */
>  	new = &new_sl->state;
>  	err = bpf_copy_verifier_state(new, cur);
> -	if (err) {
> -		bpf_free_verifier_state(new, false);
> -		kfree(new_sl);
> -		return err;
> -	}
> +	if (err)
> +		goto free_verifier_state;
> +
>  	new->insn_idx = insn_idx;
>  	verifier_bug_if(new->branches != 1, env,
>  			"%s:branches_to_explore=%d insn %d",
>  			__func__, new->branches, insn_idx);
>  	err = maybe_enter_scc(env, new);
> -	if (err) {
> -		bpf_free_verifier_state(new, false);
> -		kfree(new_sl);
> -		return err;
> -	}
> +	if (err)
> +		goto free_verifier_state;
>  
>  	cur->parent = new;
>  	cur->first_insn_idx = insn_idx;
> @@ -1588,4 +1583,9 @@ int bpf_is_state_visited(struct bpf_verifier_env *env, int insn_idx)
>  	bpf_clear_jmp_history(cur);
>  	list_add(&new_sl->node, head);
>  	return 0;
> +
> +free_verifier_state:
> +	bpf_free_verifier_state(new, false);
> +	kfree(new_sl);
> +	return err;
>  }


  reply	other threads:[~2026-06-17 19:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 19:30 Markus Elfring
2026-06-17 19:48 ` Emil Tsalapatis [this message]
2026-06-17 19:55   ` [PATCH RESEND bpf-next] " Markus Elfring
2026-06-22  1:06     ` Alexei Starovoitov
2026-06-22  7:42       ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DJBL1JEE322B.28EZ7GUNTJP99@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=Markus.Elfring@web.de \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome