aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@redhat.com>2019-02-08 15:57:37 -0500
committerPetr Mladek <pmladek@suse.com>2019-02-12 04:58:47 -0500
commitfbb76d579dff4a2e332566dcd1d5979ac92bc34b (patch)
tree70a6a8efcec81458ff50b1774469805af3d8db54
parenta087cdd4073b78f4739ce6709daeb4f3267b4dbf (diff)
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>
-rw-r--r--tools/testing/selftests/livepatch/functions.sh19
1 files changed, 7 insertions, 12 deletions
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index c7b9fb45d7c9..30195449c63c 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -55,11 +55,10 @@ function is_livepatch_mod() {
55 55
56function __load_mod() { 56function __load_mod() {
57 local mod="$1"; shift 57 local mod="$1"; shift
58 local args="$*"
59 58
60 local msg="% modprobe $mod $args" 59 local msg="% modprobe $mod $*"
61 log "${msg%% }" 60 log "${msg%% }"
62 ret=$(modprobe "$mod" "$args" 2>&1) 61 ret=$(modprobe "$mod" "$@" 2>&1)
63 if [[ "$ret" != "" ]]; then 62 if [[ "$ret" != "" ]]; then
64 die "$ret" 63 die "$ret"
65 fi 64 fi
@@ -75,12 +74,11 @@ function __load_mod() {
75# params - module parameters to pass to modprobe 74# params - module parameters to pass to modprobe
76function load_mod() { 75function load_mod() {
77 local mod="$1"; shift 76 local mod="$1"; shift
78 local args="$*"
79 77
80 is_livepatch_mod "$mod" && 78 is_livepatch_mod "$mod" &&
81 die "use load_lp() to load the livepatch module $mod" 79 die "use load_lp() to load the livepatch module $mod"
82 80
83 __load_mod "$mod" "$args" 81 __load_mod "$mod" "$@"
84} 82}
85 83
86# load_lp_nowait(modname, params) - load a kernel module with a livepatch 84# load_lp_nowait(modname, params) - load a kernel module with a livepatch
@@ -89,12 +87,11 @@ function load_mod() {
89# params - module parameters to pass to modprobe 87# params - module parameters to pass to modprobe
90function load_lp_nowait() { 88function load_lp_nowait() {
91 local mod="$1"; shift 89 local mod="$1"; shift
92 local args="$*"
93 90
94 is_livepatch_mod "$mod" || 91 is_livepatch_mod "$mod" ||
95 die "module $mod is not a livepatch" 92 die "module $mod is not a livepatch"
96 93
97 __load_mod "$mod" "$args" 94 __load_mod "$mod" "$@"
98 95
99 # Wait for livepatch in sysfs ... 96 # Wait for livepatch in sysfs ...
100 loop_until '[[ -e "/sys/kernel/livepatch/$mod" ]]' || 97 loop_until '[[ -e "/sys/kernel/livepatch/$mod" ]]' ||
@@ -106,9 +103,8 @@ function load_lp_nowait() {
106# params - module parameters to pass to modprobe 103# params - module parameters to pass to modprobe
107function load_lp() { 104function load_lp() {
108 local mod="$1"; shift 105 local mod="$1"; shift
109 local args="$*"
110 106
111 load_lp_nowait "$mod" "$args" 107 load_lp_nowait "$mod" "$@"
112 108
113 # Wait until the transition finishes ... 109 # Wait until the transition finishes ...
114 loop_until 'grep -q '^0$' /sys/kernel/livepatch/$mod/transition' || 110 loop_until 'grep -q '^0$' /sys/kernel/livepatch/$mod/transition' ||
@@ -120,11 +116,10 @@ function load_lp() {
120# params - module parameters to pass to modprobe 116# params - module parameters to pass to modprobe
121function load_failing_mod() { 117function load_failing_mod() {
122 local mod="$1"; shift 118 local mod="$1"; shift
123 local args="$*"
124 119
125 local msg="% modprobe $mod $args" 120 local msg="% modprobe $mod $*"
126 log "${msg%% }" 121 log "${msg%% }"
127 ret=$(modprobe "$mod" "$args" 2>&1) 122 ret=$(modprobe "$mod" "$@" 2>&1)
128 if [[ "$ret" == "" ]]; then 123 if [[ "$ret" == "" ]]; then
129 die "$mod unexpectedly loaded" 124 die "$mod unexpectedly loaded"
130 fi 125 fi