Skip to contentSkip to conversation

of: unittest: Unlock on error in unittest_data_add()

PATCH Applied Dan Carpenter 3 participants 3 messages Apr 30, 2025 – May 9, 2025

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

PATCH 1/1 of: unittest: Unlock on error in unittest_data_add()

The of_overlay_mutex_unlock() was accidentally deleted if "of_root" is NULL. Change this to a goto unlock.

Fixes d1eabd218ede ("of: unittest: treat missing of_root as error instead of fixing up")
---
 drivers/of/unittest.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/of/unittest.c +6 -4
index 64d301893af7..eeb370e0f507 100644
@@ -2029,15 +2029,16 @@ static int __init unittest_data_add(void)
 	rc = of_resolve_phandles(unittest_data_node);
 	if (rc) {
 		pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc);
-		of_overlay_mutex_unlock();
-		return -EINVAL;
+		rc = -EINVAL;
+		goto unlock;
 	}
 
 	/* attach the sub-tree to live tree */
 	if (!of_root) {
 		pr_warn("%s: no live tree to attach sub-tree\n", __func__);
 		kfree(unittest_data);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto unlock;
 	}
 
 	EXPECT_BEGIN(KERN_INFO,
@@ -2056,9 +2057,10 @@ static int __init unittest_data_add(void)
 	EXPECT_END(KERN_INFO,
 		   "Duplicate name in testcase-data, renamed to \"duplicate-name#1\"");
 
+unlock:
 	of_overlay_mutex_unlock();
 
-	return 0;
+	return rc;
 }
 
 #ifdef CONFIG_OF_OVERLAY
Signature · 1 line
2.47.2
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

The of_overlay_mutex_unlock() was accidentally deleted if "of_root" is NULL. Change this to a goto unlock.

Fixes d1eabd218ede ("of: unittest: treat missing of_root as error instead of fixing up")
---
 drivers/of/unittest.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Applied, thanks!