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

ACPI / sysfs: Add support to allow leading "\" missing in trace_method_name.

Since _SB.PCI0 can be used as relative path from root and can be easily
converted into internal trace_method_name format, we allow users to specify
trace_method_name using relative paths from root.
Note this is useful for grub2 for which users failed to pass "\" from the
grub configuration file.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Lv Zheng and committed by
Rafael J. Wysocki
a0186bcf 7901a052

+13 -15
+13 -15
drivers/acpi/sysfs.c
··· 164 164 module_param_cb(debug_layer, &param_ops_debug_layer, &acpi_dbg_layer, 0644); 165 165 module_param_cb(debug_level, &param_ops_debug_level, &acpi_dbg_level, 0644); 166 166 167 - static char* trace_method_name; 168 - static bool trace_method_kmalloced; 167 + static char trace_method_name[1024]; 169 168 170 169 int param_set_trace_method_name(const char *val, const struct kernel_param *kp) 171 170 { 172 171 u32 saved_flags = 0; 172 + bool is_abs_path = true; 173 173 174 - if (strlen(val) > 1024) { 174 + if (*val != '\\') 175 + is_abs_path = false; 176 + 177 + if ((is_abs_path && strlen(val) > 1023) || 178 + (!is_abs_path && strlen(val) > 1022)) { 175 179 pr_err("%s: string parameter too long\n", kp->name); 176 180 return -ENOSPC; 177 181 } ··· 191 187 acpi_gbl_trace_dbg_layer, 192 188 0); 193 189 194 - if (trace_method_kmalloced) 195 - kfree(trace_method_name); 196 - trace_method_name = NULL; 197 - trace_method_kmalloced = false; 198 - 199 190 /* This is a hack. We can't kmalloc in early boot. */ 200 - if (slab_is_available()) { 201 - trace_method_name = kstrdup(val, GFP_KERNEL); 202 - if (!trace_method_name) 203 - return -ENOMEM; 204 - trace_method_kmalloced = true; 205 - } else 206 - trace_method_name = (char *)val; 191 + if (is_abs_path) 192 + strcpy(trace_method_name, val); 193 + else { 194 + trace_method_name[0] = '\\'; 195 + strcpy(trace_method_name+1, val); 196 + } 207 197 208 198 /* Restore the original tracer state */ 209 199 (void)acpi_debug_trace(trace_method_name,