Skip to contentSkip to conversation

kernel/bpf/cgroup.c:513 prog_list_replace_item() error: we previously assumed 'pl->link' could be null (see line 510)

PATCH New Dan Carpenter 1 participant 1 message May 18

lore
Share & tools
lore
#0 lore raw

PATCH 9/12 kernel/bpf/cgroup.c:513 prog_list_replace_item() error: we previously assumed 'pl->link' could be null (see line 510)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/martin.lau/bpf-next.git cgrp.struct_ops.v8
head:   1ae5eccb04d5d8c62c310b206b5e5dc4ff1d9c71
commit: 32e27daf9a1563276f88eb17d076f61f8cc8b502 [9/12] bpf: Add infrastructure to support attaching struct_ops to cgroups
config: nios2-randconfig-r073-20260517 (https://download.01.org/0day-ci/archive/20260517/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
smatch: v0.5.0-9185-gbcc58b9c

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
kernel/bpf/cgroup.c:513 prog_list_replace_item() error: we previously assumed 'pl->link' could be null (see line 510)

vim +513 kernel/bpf/cgroup.c

95b27b9bf36972 Martin KaFai Lau 2026-05-13  508  static void prog_list_replace_item(struct bpf_prog_list *pl, struct bpf_prog_array_item *item)
95b27b9bf36972 Martin KaFai Lau 2026-05-13  509  {
32e27daf9a1563 Martin KaFai Lau 2026-05-12 @510  	if (pl->link && pl->link->map)
                                                            ^^^^^^^^

If pl->link is NULL

32e27daf9a1563 Martin KaFai Lau 2026-05-12  511  		WRITE_ONCE(item->kdata, bpf_struct_ops_map_kdata(pl->link->map));
32e27daf9a1563 Martin KaFai Lau 2026-05-12  512  	else
95b27b9bf36972 Martin KaFai Lau 2026-05-13 @513  		WRITE_ONCE(item->prog, pl->link->link.prog);
                                                                                       ^^^^^^^^

it's going to crash here.

95b27b9bf36972 Martin KaFai Lau 2026-05-13 514 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki