cpufreq: qcom-hw: Add missing null pointer check
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Tue, 14 Feb 2023 09:41:15 +0000 (15:11 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 14 Feb 2023 14:06:10 +0000 (15:06 +0100)
of_device_get_match_data() may return NULL, so add a check to prevent
potential null pointer dereference.

Issue reported by Qualcomm's internal static analysis tool.

Fixes: 4f7961706c63 ("cpufreq: qcom-hw: Move soc_data to struct qcom_cpufreq")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/qcom-cpufreq-hw.c

index 957cf6bb8c0523ee54b468bc33481c192dbca14c..d3f55ca06ed346614b80ffd91be5b1e5e47a786e 100644 (file)
@@ -706,6 +706,8 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        qcom_cpufreq.soc_data = of_device_get_match_data(dev);
+       if (!qcom_cpufreq.soc_data)
+               return -ENODEV;
 
        clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, num_domains), GFP_KERNEL);
        if (!clk_data)