Commit 8f325a0
bpf: add a check to make static analysers happy
In [1] Dan Carpenter reported that the following code makes the
Smatch static analyser unhappy:
17904 value = map->ops->map_lookup_elem(map, &i);
17905 if (!value)
17906 return -EINVAL;
--> 17907 items[i - start] = value->xlated_off;
The analyser assumes that the `value` variable may contain an error
and thus it should be properly checked before the dereference.
On practice this will never happen as array maps do not return
error values in map_lookup_elem, but to make the Smatch and other
possible analysers happy this patch adds a formal check.
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/bpf/[email protected]/ [1]
Fixes: 493d9e0 ("bpf, x86: add support for indirect jumps")
Signed-off-by: Anton Protopopov <[email protected]>1 parent bfb0726 commit 8f325a0
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17929 | 17929 | | |
17930 | 17930 | | |
17931 | 17931 | | |
17932 | | - | |
| 17932 | + | |
| 17933 | + | |
| 17934 | + | |
| 17935 | + | |
| 17936 | + | |
| 17937 | + | |
| 17938 | + | |
17933 | 17939 | | |
17934 | 17940 | | |
17935 | 17941 | | |
| |||
0 commit comments