Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

livepatch/selftests: use "$@" to preserve argument list

The livepatch selftest functions.sh library uses "$*" and an
intermediate variable to extract and then pass arguments from function
to function call. The effect of this combination is that the argument
list is flattened into a single argument. Sometimes this is benign, but
in cases like __load_mod(), the modprobe invocation will interpret all
the module parameters as a single parameter.

Drop the intermediate variable and use the "$@" special parameter as
described in the bash manual.

Link: https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Petr Mladek <pmladek@suse.com>

authored by

Joe Lawrence and committed by
Petr Mladek
fbb76d57 a087cdd4

+7 -12
+7 -12
tools/testing/selftests/livepatch/functions.sh
··· 55 55 56 56 function __load_mod() { 57 57 local mod="$1"; shift 58 - local args="$*" 59 58 60 - local msg="% modprobe $mod $args" 59 + local msg="% modprobe $mod $*" 61 60 log "${msg%% }" 62 - ret=$(modprobe "$mod" "$args" 2>&1) 61 + ret=$(modprobe "$mod" "$@" 2>&1) 63 62 if [[ "$ret" != "" ]]; then 64 63 die "$ret" 65 64 fi ··· 74 75 # params - module parameters to pass to modprobe 75 76 function load_mod() { 76 77 local mod="$1"; shift 77 - local args="$*" 78 78 79 79 is_livepatch_mod "$mod" && 80 80 die "use load_lp() to load the livepatch module $mod" 81 81 82 - __load_mod "$mod" "$args" 82 + __load_mod "$mod" "$@" 83 83 } 84 84 85 85 # load_lp_nowait(modname, params) - load a kernel module with a livepatch ··· 87 89 # params - module parameters to pass to modprobe 88 90 function load_lp_nowait() { 89 91 local mod="$1"; shift 90 - local args="$*" 91 92 92 93 is_livepatch_mod "$mod" || 93 94 die "module $mod is not a livepatch" 94 95 95 - __load_mod "$mod" "$args" 96 + __load_mod "$mod" "$@" 96 97 97 98 # Wait for livepatch in sysfs ... 98 99 loop_until '[[ -e "/sys/kernel/livepatch/$mod" ]]' || ··· 103 106 # params - module parameters to pass to modprobe 104 107 function load_lp() { 105 108 local mod="$1"; shift 106 - local args="$*" 107 109 108 - load_lp_nowait "$mod" "$args" 110 + load_lp_nowait "$mod" "$@" 109 111 110 112 # Wait until the transition finishes ... 111 113 loop_until 'grep -q '^0$' /sys/kernel/livepatch/$mod/transition' || ··· 116 120 # params - module parameters to pass to modprobe 117 121 function load_failing_mod() { 118 122 local mod="$1"; shift 119 - local args="$*" 120 123 121 - local msg="% modprobe $mod $args" 124 + local msg="% modprobe $mod $*" 122 125 log "${msg%% }" 123 - ret=$(modprobe "$mod" "$args" 2>&1) 126 + ret=$(modprobe "$mod" "$@" 2>&1) 124 127 if [[ "$ret" == "" ]]; then 125 128 die "$mod unexpectedly loaded" 126 129 fi