[jolsa-perf:bpf/tramp_22 21/21] kernel/bpf/trampoline.c:941:11: warning: variable 'id_multi' is uninitialized when used here
From: kernel test robot
Date: Tue Jul 05 2022 - 23:07:20 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git bpf/tramp_22
head: 1d891c46bb689a24985cea58f4eddb053d6b1331
commit: 1d891c46bb689a24985cea58f4eddb053d6b1331 [21/21] bpf: Add support to attach multi trampolines
config: i386-randconfig-a011 (https://download.01.org/0day-ci/archive/20220706/202207061003.NznoJ2YS-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 142aca7741d5b06207e87bf4880fbe308c8d6823)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?id=1d891c46bb689a24985cea58f4eddb053d6b1331
git remote add jolsa-perf https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
git fetch --no-tags jolsa-perf bpf/tramp_22
git checkout 1d891c46bb689a24985cea58f4eddb053d6b1331
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash kernel/bpf/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
>> kernel/bpf/trampoline.c:941:11: warning: variable 'id_multi' is uninitialized when used here [-Wuninitialized]
id_add(id_multi, id->id[i]);
^~~~~~~~
kernel/bpf/trampoline.c:924:31: note: initialize the variable 'id_multi' to silence this warning
struct bpf_tramp_id *id_multi, *id_singles;
^
= NULL
>> kernel/bpf/trampoline.c:950:10: warning: variable 'id_singles' is uninitialized when used here [-Wuninitialized]
id_add(id_singles, id->id[i]);
^~~~~~~~~~
kernel/bpf/trampoline.c:924:44: note: initialize the variable 'id_singles' to silence this warning
struct bpf_tramp_id *id_multi, *id_singles;
^
= NULL
2 warnings generated.
vim +/id_multi +941 kernel/bpf/trampoline.c
921
922 int bpf_trampoline_multi_attach(struct bpf_tramp_prog *tp, struct bpf_tramp_id *id)
923 {
924 struct bpf_tramp_id *id_multi, *id_singles;
925 struct bpf_trampoline *tr;
926 LIST_HEAD(upd);
927 int i, err = -EINVAL;
928 u64 key;
929
930 mutex_lock(&trampoline_mutex);
931 list_for_each_entry(tr, &multi_trampolines, multi.list) {
932 if (id_and(id, tr->multi.id_multi))
933 goto out_unlock;
934 }
935
936 for (i = 0; i < id->cnt; i++) {
937 key = bpf_trampoline_compute_key(tp->prog, tp->prog->aux->attach_btf,
938 id->id[i]);
939 tr = __bpf_trampoline_lookup(key);
940 if (!tr) {
> 941 id_add(id_multi, id->id[i]);
942 continue;
943 }
944 mutex_lock(&tr->mutex);
945 err = __bpf_trampoline_link_prog(tp, tr, &upd);
946 if (err) {
947 mutex_unlock(&tr->mutex);
948 goto out_rollback;
949 }
> 950 id_add(id_singles, id->id[i]);
951 }
952
953 tr = bpf_trampoline_alloc();
954 if (!tr)
955 goto out_rollback;
956
957 err = __bpf_trampoline_link_prog(tp, tr, &upd);
958 if (err)
959 goto out_rollback;
960
961 err = bpf_tramp_update_set(&upd);
962 if (err)
963 goto out_rollback;
964
965 tr->multi.id_multi = id_multi;
966 tr->multi.id_singles = id_singles;
967 list_add_tail(&tr->multi.list, &multi_trampolines);
968
969 list_for_each_entry(tr, &upd, update.list) {
970 bpf_trampoline_commit(tr);
971 mutex_unlock(&tr->mutex);
972 }
973
974 out_unlock:
975 mutex_unlock(&trampoline_mutex);
976 return 0;
977 out_rollback:
978 list_for_each_entry(tr, &upd, update.list) {
979 bpf_trampoline_rollback(tr);
980 mutex_unlock(&tr->mutex);
981 bpf_trampoline_put(tr);
982 }
983 mutex_unlock(&trampoline_mutex);
984 return err;
985 }
986
--
0-DAY CI Kernel Test Service
https://01.org/lkp