BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 09/10] libbpf: Add ring__new() and ring__free()
Date: Mon, 23 Nov 2026 21:20:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-230078@kernel.org> (raw)
In-Reply-To: <672644a3994795301e66804ad18983a65efd0d75.1795467315.git.memxor@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] libbpf: ring__new() bypasses libbpf_err_ptr() on error return
  paths
--

commit 3d8ab4da44ad53020ae84560a8e42655f36bab40
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>

libbpf: Add ring__new() and ring__free()

This commit adds ring__new() and ring__free() to allow creating and freeing a
standalone struct ring directly from a ring buffer map fd without a
ring_buffer manager.

> diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c
> index 90ed354118de3..e794448dcb891 100644
> --- a/tools/lib/bpf/ringbuf.c
> +++ b/tools/lib/bpf/ringbuf.c
[ ... ]
> @@ -204,6 +206,44 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd,
>  	return libbpf_err(err);
>  }
>  
> +struct ring *ring__new(int map_fd, const struct ring_opts *opts)
> +{
> +	struct ring *r;
> +	int err;
> +
> +	if (!OPTS_VALID(opts, ring_opts))
> +		return errno = EINVAL, NULL;
> +
> +	r = calloc(1, sizeof(*r));
> +	if (!r)
> +		return errno = ENOMEM, NULL;
> +
> +	r->page_size = getpagesize();
> +	r->standalone = true;
> +
> +	err = ringbuf_map_ring(r, map_fd);
> +	if (err) {
> +		ringbuf_free_ring(r);
> +		return errno = -err, NULL;
> +	}
> +
> +	return r;
> +}

[Severity: Medium]
Should ring__new() wrap its error returns with libbpf_err_ptr() (-EINVAL,
-ENOMEM, and err) instead of setting errno and returning NULL directly, matching
other public pointer-returning libbpf APIs?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795467315.git.memxor@gmail.com?part=9

  reply	other threads:[~2026-11-23 21:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 21:13 [PATCH bpf-next v1 00/10] Ring Buffer Iterator API Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 01/10] bpf: Order record data after the producer position in overwrite mode Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 02/10] bpf: Keep an overwritable ring buffer readable while it is overwritten Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 03/10] bpf, docs: Document the overwrite mode of BPF ring buffer Kumar Kartikeya Dwivedi
2026-11-23 21:46   ` bot+bpf-ci
2026-11-23 21:13 ` [PATCH bpf-next v1 04/10] libbpf: Account for the overwrite position in ring__avail_data_size() Kumar Kartikeya Dwivedi
2026-11-23 21:22   ` sashiko-bot
2026-11-23 21:13 ` [PATCH bpf-next v1 05/10] libbpf: Add a record API for consuming BPF ring buffers Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 06/10] libbpf: Add ring_buffer__wait() Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 07/10] libbpf: Support overwritable ring buffers in the record API Kumar Kartikeya Dwivedi
2026-11-23 21:28   ` sashiko-bot
2026-11-23 21:13 ` [PATCH bpf-next v1 08/10] libbpf: Split ring setup out of ring_buffer__add() Kumar Kartikeya Dwivedi
2026-11-23 21:13 ` [PATCH bpf-next v1 09/10] libbpf: Add ring__new() and ring__free() Kumar Kartikeya Dwivedi
2026-11-23 21:20   ` sashiko-bot [this message]
2026-11-23 21:13 ` [PATCH bpf-next v1 10/10] selftests/bpf: Add tests for the ring buffer record API Kumar Kartikeya Dwivedi

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=sashiko-outbox-230078@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sashiko-reviews@lists.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