Skip to contentSkip to conversation

cpufreq: loongson3: Check for error code from devm_mutex_init() call

PATCH Applied Andy Shevchenko 2 participants 3 messages Oct 31, 2024 – Nov 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq: loongson3: Check for error code from devm_mutex_init() call

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")

---
v2: renamed loongson --> loongson3 in the Subject (Huacai)

 drivers/cpufreq/loongson3_cpufreq.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/loongson3_cpufreq.c +5 -2
index 61ebebf69455..bd34bf0fafa5 100644
@@ -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)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw
Quoted 4 lines · Andy Shevchenko

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.

Any comments? Can this be applied now for fixes, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

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.

Any comments? Can this be applied now for fixes, please?

Applied. Thanks.

Signature · 1 line
viresh