Skip to content

Commit cdc06f9

Browse files
jhovoldrafaeljw
authored andcommitted
cpuidle: qcom-spm: fix device and OF node leaks at probe
Make sure to drop the reference to the saw device taken by of_find_device_by_node() after retrieving its driver data during probe(). Also drop the reference to the CPU node sooner to avoid leaking it in case there is no saw node or device. Fixes: 60f3692 ("cpuidle: qcom_spm: Detach state machine from main SPM handling") Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9141833 commit cdc06f9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/cpuidle/cpuidle-qcom-spm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,23 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)
9696
return -ENODEV;
9797

9898
saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
99+
of_node_put(cpu_node);
99100
if (!saw_node)
100101
return -ENODEV;
101102

102103
pdev = of_find_device_by_node(saw_node);
103104
of_node_put(saw_node);
104-
of_node_put(cpu_node);
105105
if (!pdev)
106106
return -ENODEV;
107107

108108
data = devm_kzalloc(cpuidle_dev, sizeof(*data), GFP_KERNEL);
109-
if (!data)
109+
if (!data) {
110+
put_device(&pdev->dev);
110111
return -ENOMEM;
112+
}
111113

112114
data->spm = dev_get_drvdata(&pdev->dev);
115+
put_device(&pdev->dev);
113116
if (!data->spm)
114117
return -EINVAL;
115118

0 commit comments

Comments
 (0)