Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use malloc and free for cv_stack to avoid dangling pointer warning #1417

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

gemenerik
Copy link
Member

@gemenerik gemenerik commented Oct 15, 2024

Before the change, running make cf2_defconfig and make clean generated warnings about dangling pointers in the configuration process.

In function ‘dep_stack_insert’,
    inlined from ‘sym_check_print_recursive’ at ../scripts/kconfig/symbol.c:1103:3,
    inlined from ‘sym_check_deps’ at ../scripts/kconfig/symbol.c:1280:3:
../scripts/kconfig/symbol.c:1079:19: warning: storing the address of local variable ‘cv_stack’ in ‘check_top’ [-Wdangling-pointer=]
 1079 |         check_top = stack;
      |         ~~~~~~~~~~^~~~~~~
../scripts/kconfig/symbol.c: In function ‘sym_check_deps’:
../scripts/kconfig/symbol.c:1100:26: note: ‘cv_stack’ declared here
 1100 |         struct dep_stack cv_stack;
      |                          ^~~~~~~~
../scripts/kconfig/symbol.c:1070:4: note: ‘check_top’ declared here
 1070 | } *check_top;
      |    ^~~~~~~~~

After the update, the command completes without any warnings.

The changes in this PR shouldn't practically change anything except acknowledge that we are responsible for cv_stack. The function in question is called during recursive dependency checking. I tested this PR by deliberately introducing recursive dependency in kconfig.

@ataffanel ataffanel merged commit 489f344 into master Oct 15, 2024
25 checks passed
@ataffanel ataffanel deleted the rik/kconfig_warning branch October 15, 2024 14:17
@ataffanel
Copy link
Member

Merged! I cannot verify the full implication of this malloc and if any early free is possible but since this is a diagnostic part of the build system it is unlikely to cause any problem and if it does it will be visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants