Skip to contentSkip to conversation

selftests/bpf: specify expected instructions in test_verifier tests

bug report Dan Carpenter 2 participants 2 messages Jun 6, 2023 BPF

lore
Share & tools
lore
#0 lore raw

Hello Eduard Zingerman,

This is a semi-automatic email about new static checker warnings.

The patch 933ff53191eb: "selftests/bpf: specify expected instructions in test_verifier tests" from Jun 21, 2022, leads to the following Smatch complaint:

./tools/testing/selftests/bpf/test_verifier.c:1365 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 1364)

./tools/testing/selftests/bpf/test_verifier.c
1363 *cnt = xlated_prog_len / buf_element_size;
1364 *buf = calloc(*cnt, buf_element_size);
1365 if (!buf) {

This should be if (!*buf) {

  1366			perror("can't allocate xlated program buffer");
  1367			return -ENOMEM;

regards,
dan carpenter

maintainer
#1 lore raw
Quoted 16 lines · Dan Carpenter

Hello Eduard Zingerman,

This is a semi-automatic email about new static checker warnings.

The patch 933ff53191eb: "selftests/bpf: specify expected instructions in test_verifier tests" from Jun 21, 2022, leads to the following Smatch complaint:

./tools/testing/selftests/bpf/test_verifier.c:1365 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 1364)

./tools/testing/selftests/bpf/test_verifier.c
1363 *cnt = xlated_prog_len / buf_element_size;
1364 *buf = calloc(*cnt, buf_element_size);
1365 if (!buf) {

Quoted 4 lines

This should be if (!*buf) {

  1366			perror("can't allocate xlated program buffer");
  1367			return -ENOMEM;

Hi Dan,

Thank you for this bug report, I'll submit a fixed version.

Thanks,
Eduard

Quoted 3 lines

regards,
dan carpenter