]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: loongson3: Check for error code from devm_mutex_init() call
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 31 Oct 2024 13:46:34 +0000 (15:46 +0200)
committerViresh Kumar <viresh.kumar@linaro.org>
Mon, 11 Nov 2024 04:10:03 +0000 (09:40 +0530)
Even if it's not critical, the avoidance of checking the error code
from devm_mutex_init() call today diminishes the point of using devm
variant of it. Tomorrow it may even leak something. Add the missed
check.

Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/loongson3_cpufreq.c

index 6b5e6798d9a283ca02068001b4e4a1e3db304cb1..a923e196ec86e73376f63023031d0c1c60d2d36f 100644 (file)
@@ -346,8 +346,11 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev)
 {
        int i, ret;
 
-       for (i = 0; i < MAX_PACKAGES; i++)
-               devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]);
+       for (i = 0; i < MAX_PACKAGES; i++) {
+               ret = devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]);
+               if (ret)
+                       return ret;
+       }
 
        ret = do_service_request(0, 0, CMD_GET_VERSION, 0, 0);
        if (ret <= 0)