trace_boot_init_histograms misses NULL pointer checks for kstrdup failure. Link: https://lkml.kernel.org/r/20211015195550.22742-1-mathieu.desnoyers@efficios.com
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -430,6 +430,8 @@ trace_boot_init_histograms(struct trace_event_file *file, · 429 unmodified lines | |||
| 430 | /* All digit started node should be instances. */ | 430 | /* All digit started node should be instances. */ |
| 431 | if (trace_boot_compose_hist_cmd(node, buf, size) == 0) { | 431 | if (trace_boot_compose_hist_cmd(node, buf, size) == 0) { |
| 432 | tmp = kstrdup(buf, GFP_KERNEL); | 432 | tmp = kstrdup(buf, GFP_KERNEL); |
| 433 | if (!tmp) | ||
| 434 | return; | ||
| 433 | if (trigger_process_regex(file, buf) < 0) | 435 | if (trigger_process_regex(file, buf) < 0) |
| 434 | pr_err("Failed to apply hist trigger: %s\n", tmp); | 436 | pr_err("Failed to apply hist trigger: %s\n", tmp); |
| 435 | kfree(tmp); | 437 | kfree(tmp); |
| @@ -439,6 +441,8 @@ trace_boot_init_histograms(struct trace_event_file *file, · 3 unmodified lines | |||
| 439 | if (xbc_node_find_subkey(hnode, "keys")) { | 441 | if (xbc_node_find_subkey(hnode, "keys")) { |
| 440 | if (trace_boot_compose_hist_cmd(hnode, buf, size) == 0) { | 442 | if (trace_boot_compose_hist_cmd(hnode, buf, size) == 0) { |
| 441 | tmp = kstrdup(buf, GFP_KERNEL); | 443 | tmp = kstrdup(buf, GFP_KERNEL); |
| 444 | if (!tmp) | ||
| 445 | return; | ||
| 442 | if (trigger_process_regex(file, buf) < 0) | 446 | if (trigger_process_regex(file, buf) < 0) |
| 443 | pr_err("Failed to apply hist trigger: %s\n", tmp); | 447 | pr_err("Failed to apply hist trigger: %s\n", tmp); |
| 444 | kfree(tmp); | 448 | kfree(tmp); |