Commit 9d0d266
kconfig: recursive checks drop file/lineno
This prevents segfault when getting filename and lineno in recursive
checks.
If the following snippet is found in Kconfig:
[Test code 1]
config FOO
bool
depends on BAR
select BAR
... without BAR defined; then there is a segfault.
Kconfig:34:error: recursive dependency detected!
Kconfig:34: symbol FOO depends on BAR
make[4]: *** [scripts/kconfig/Makefile:85: allnoconfig] Segmentation fault
This is because of the following. BAR is a fake entry created by
sym_lookup() with prop being NULL. In the recursive check, there is a
NULL check for prop to fall back to stack->sym->prop if stack->prop is
NULL. However, in this case, stack->sym points to the fake BAR entry
created by sym_lookup(), so prop is still NULL. prop was then referenced
without additional NULL checks, causing segfault.
As the previous email thread suggests, the file and lineno for select is
also wrong:
[Test code 2]
config FOO
bool
config BAR
bool
config FOO
bool "FOO"
depends on BAR
select BAR
$ make defconfig
*** Default configuration is based on 'x86_64_defconfig'
Kconfig:1:error: recursive dependency detected!
Kconfig:1: symbol FOO depends on BAR
Kconfig:4: symbol BAR is selected by FOO
[...]
Kconfig:4 should be Kconfig:10.
This patch deletes the wrong and segfault-prone filename/lineno
inference completely. With this patch, Test code 1 yields:
error: recursive dependency detected!
symbol FOO depends on BAR
symbol BAR is selected by FOO
Signed-off-by: HONG Yifan <elsk@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>1 parent 301c109 commit 9d0d266
File tree
2 files changed
+30
-48
lines changed- scripts/kconfig
- tests/err_recursive_dep
2 files changed
+30
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1074 | 1074 | | |
1075 | 1075 | | |
1076 | 1076 | | |
1077 | | - | |
1078 | 1077 | | |
1079 | | - | |
1080 | 1078 | | |
| 1079 | + | |
1081 | 1080 | | |
1082 | 1081 | | |
1083 | 1082 | | |
| |||
1096 | 1095 | | |
1097 | 1096 | | |
1098 | 1097 | | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
| 1098 | + | |
| 1099 | + | |
1111 | 1100 | | |
1112 | | - | |
1113 | | - | |
| 1101 | + | |
1114 | 1102 | | |
1115 | 1103 | | |
1116 | 1104 | | |
1117 | 1105 | | |
1118 | | - | |
1119 | | - | |
| 1106 | + | |
1120 | 1107 | | |
1121 | 1108 | | |
1122 | 1109 | | |
1123 | | - | |
1124 | | - | |
| 1110 | + | |
1125 | 1111 | | |
1126 | 1112 | | |
1127 | 1113 | | |
1128 | | - | |
1129 | | - | |
| 1114 | + | |
1130 | 1115 | | |
1131 | 1116 | | |
1132 | | - | |
1133 | | - | |
| 1117 | + | |
1134 | 1118 | | |
1135 | 1119 | | |
1136 | | - | |
1137 | | - | |
| 1120 | + | |
1138 | 1121 | | |
1139 | | - | |
| 1122 | + | |
1140 | 1123 | | |
1141 | 1124 | | |
1142 | | - | |
1143 | | - | |
| 1125 | + | |
1144 | 1126 | | |
1145 | | - | |
| 1127 | + | |
1146 | 1128 | | |
1147 | 1129 | | |
1148 | 1130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
0 commit comments