History

tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks

trace_boot_init_histograms misses NULL pointer checks for kstrdup failure. Link: https://lkml.kernel.org/r/20211015195550.22742-1-mathieu.desnoyers@efficios.com

Mathieu Desnoyers committed 5 years ago

Commit 3c20bd31 parent aeafcb81 file · +4 −0Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_boot.c+4−0
@@ -430,6 +430,8 @@ trace_boot_init_histograms(struct trace_event_file *file, · 429 unmodified lines
430430 /* All digit started node should be instances. */
431431 if (trace_boot_compose_hist_cmd(node, buf, size) == 0) {
432432 tmp = kstrdup(buf, GFP_KERNEL);
433+ if (!tmp)
434+ return;
433435 if (trigger_process_regex(file, buf) < 0)
434436 pr_err("Failed to apply hist trigger: %s\n", tmp);
435437 kfree(tmp);
@@ -439,6 +441,8 @@ trace_boot_init_histograms(struct trace_event_file *file, · 3 unmodified lines
439441 if (xbc_node_find_subkey(hnode, "keys")) {
440442 if (trace_boot_compose_hist_cmd(hnode, buf, size) == 0) {
441443 tmp = kstrdup(buf, GFP_KERNEL);
444+ if (!tmp)
445+ return;
442446 if (trigger_process_regex(file, buf) < 0)
443447 pr_err("Failed to apply hist trigger: %s\n", tmp);
444448 kfree(tmp);