drivers/perf: arm_pmu: avoid NULL dereference when not using devicetree
authorWill Deacon <will.deacon@arm.com>
Mon, 21 Mar 2016 11:07:15 +0000 (11:07 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 21 Mar 2016 11:36:17 +0000 (11:36 +0000)
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>
drivers/perf/arm_pmu.c

index 11bacc7220a1b6891da53d4db850b6b4ea741b24..32346b5a8a119789c1857c90ec13902616ace318 100644 (file)
@@ -1002,8 +1002,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
        }
 
        if (ret) {
-               pr_info("%s: failed to probe PMU! Error %i\n",
-                       node->full_name, ret);
+               pr_info("%s: failed to probe PMU!\n", of_node_full_name(node));
                goto out_free;
        }
 
@@ -1023,8 +1022,8 @@ int arm_pmu_device_probe(struct platform_device *pdev,
 out_destroy:
        cpu_pmu_destroy(pmu);
 out_free:
-       pr_info("%s: failed to register PMU devices! Error %i\n",
-               node->full_name, ret);
+       pr_info("%s: failed to register PMU devices!\n",
+               of_node_full_name(node));
        kfree(pmu);
        return ret;
 }