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

drivers/perf: arm_pmu: avoid NULL dereference when not using devicetree

Commit c6b90653f1f7 ("drivers/perf: arm_pmu: make info messages more
verbose") breaks booting on systems where the PMU is probed without
devicetree (e.g by inspecting the MIDR of the current CPU). In this case,
pdev->dev.of_node is NULL and we shouldn't try to access its ->fullname
field when printing probe error messages.

This patch fixes the probing code to use of_node_full_name, which safely
handles NULL nodes and removes the "Error %i" part of the string, since
it's not terribly useful.

Reported-by: Guenter Roeck <private@roeck-us.net>
Signed-off-by: Will Deacon <will.deacon@arm.com>

+3 -4
+3 -4
drivers/perf/arm_pmu.c
··· 1002 1002 } 1003 1003 1004 1004 if (ret) { 1005 - pr_info("%s: failed to probe PMU! Error %i\n", 1006 - node->full_name, ret); 1005 + pr_info("%s: failed to probe PMU!\n", of_node_full_name(node)); 1007 1006 goto out_free; 1008 1007 } 1009 1008 ··· 1022 1023 out_destroy: 1023 1024 cpu_pmu_destroy(pmu); 1024 1025 out_free: 1025 - pr_info("%s: failed to register PMU devices! Error %i\n", 1026 - node->full_name, ret); 1026 + pr_info("%s: failed to register PMU devices!\n", 1027 + of_node_full_name(node)); 1027 1028 kfree(pmu); 1028 1029 return ret; 1029 1030 }