> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 95a4fa1f1e44..6416c8aa3034 100644

[ ... ]

> @@ -360,6 +366,7 @@ BPF_SKELS_LINKED := $(addprefix $(obj)/,$(LINKED_SKELS))
>
>  $(BPF_SKELS_LINKED): $(BPF_OBJS_LINKED) $(BPFTOOL)
>       @echo "  BPF GEN-OBJ " $(@:.skel.h=)
> +     echo $(Q)$(BPFTOOL) gen object $(@:.skel.h=.lbpf.o) $(addprefix 
> $(obj)/,$($(@F)-deps))
>       $(Q)$(BPFTOOL) gen object $(@:.skel.h=.lbpf.o) $(addprefix 
> $(obj)/,$($(@F)-deps))

Was this debug echo intended to be left in? The line without the @ prefix
will print the unexpanded command during the build, which looks like
leftover debug output.

> diff --git a/samples/bpf/memcg.c b/samples/bpf/memcg.c
> new file mode 100644
> index 000000000000..85432cb01c27
> --- /dev/null
> +++ b/samples/bpf/memcg.c

[ ... ]

> +     high_cgroup_id = get_cgroup_id(high_path);
> +     if (!high_cgroup_id)
> +             goto out;
> +     high_cgroup_fd = open(high_path, O_RDONLY);
> +     if (high_cgroup_fd < 0) {
> +             fprintf(stderr,
> +                     "ERROR: open high cgroup '%s' failed: %d\n",
> +                     low_path, errno);
                        ^^^^^^^^

Should this be high_path instead of low_path? The error message says
"open high cgroup" but prints low_path.

[ ... ]

> +     struct bpf_link *link = NULL, *link_low = NULL, *link_high = NULL;

[ ... ]

> +     if (over_high_ms) {

[ ... ]

> +             link_low = bpf_map__attach_struct_ops_opts(map, &opts);

[ ... ]

> +     if (use_below_low || use_below_min) {
> +             map = bpf_object__find_map_by_name(obj, "high_mcg_ops");

[ ... ]

> +             link_low = bpf_map__attach_struct_ops_opts(map, &opts);
                ^^^^^^^^

This assigns to link_low again, overwriting the previous link if both
over_high_ms and (use_below_low || use_below_min) are set. Should this
be link_high instead? The link_high variable is declared but never
assigned, and the first bpf_link would be leaked in this scenario.

[ ... ]

> +out:
> +     bpf_link__destroy(link);
> +     bpf_link__destroy(link_low);
> +     bpf_link__destroy(link_high);

Here link_high is always NULL since it was never assigned above.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21280790825

Reply via email to