Skip to content

Commit 61f7e31

Browse files
committed
ktest.pl: Prevent recursion of default variable options
If a default variable contains itself, do not recurse on it. For example: ADD_CONFIG := ${CONFIG_DIR}/temp_config DEFAULTS ADD_CONFIG = ${CONFIG_DIR}/default_config ${ADD_CONFIG} The above works because the temp variable ADD_CONFIG (is a temp because it is created with ":=") is already defined, it will be substituted in the variable option. But if it gets commented out: # ADD_CONFIG := ${CONFIG_DIR}/temp_config DEFAULTS ADD_CONFIG = ${CONFIG_DIR}/default_config ${ADD_CONFIG} Then the above will go into a recursive loop where ${ADD_CONFIG} will get replaced with the current definition of ADD_CONFIG which contains the ${ADD_CONFIG} and that will also try to get converted. ktest.pl will error after 100 attempts of recursion and fail. When replacing a variable with the default variable, if the default variable contains itself, do not replace it. Cc: "John Warthog9 Hawley" <[email protected]> Cc: Dhaval Giani <[email protected]> Cc: Greg KH <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt <[email protected]>
1 parent acd98e2 commit 61f7e31

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,10 @@ sub __eval_option {
13941394
# If a variable contains itself, use the default var
13951395
if (($var eq $name) && defined($opt{$var})) {
13961396
$o = $opt{$var};
1397-
$retval = "$retval$o";
1397+
# Only append if the default doesn't contain itself
1398+
if ($o !~ m/\$\{$var\}/) {
1399+
$retval = "$retval$o";
1400+
}
13981401
} elsif (defined($opt{$o})) {
13991402
$o = $opt{$o};
14001403
$retval = "$retval$o";

0 commit comments

Comments
 (0)