]> Git Repo - linux.git/commit
kconfig: recursive checks drop file/lineno
authorHONG Yifan <[email protected]>
Wed, 17 Jul 2024 01:50:41 +0000 (01:50 +0000)
committerMasahiro Yamada <[email protected]>
Sat, 20 Jul 2024 07:33:45 +0000 (16:33 +0900)
commit9d0d266046571f4b3e733c7eb9cf7c959f37fbdd
treec5c19c9ef8460111f8a8b7b4ce5358e8f0adde6f
parent301c10908e42657c3e6142055aa772adab6a6ef7
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 <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
scripts/kconfig/symbol.c
scripts/kconfig/tests/err_recursive_dep/expected_stderr
This page took 0.05545 seconds and 4 git commands to generate.