Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/aBHZ1DvXiBcZkWmk@stanley.mountain
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Dan Carpenter and committed by
Rob Herring (Arm)
493e6cb6 1b765f8b

+6 -4
+6 -4
drivers/of/unittest.c
··· 2029 2029 rc = of_resolve_phandles(unittest_data_node); 2030 2030 if (rc) { 2031 2031 pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); 2032 - of_overlay_mutex_unlock(); 2033 - return -EINVAL; 2032 + rc = -EINVAL; 2033 + goto unlock; 2034 2034 } 2035 2035 2036 2036 /* attach the sub-tree to live tree */ 2037 2037 if (!of_root) { 2038 2038 pr_warn("%s: no live tree to attach sub-tree\n", __func__); 2039 2039 kfree(unittest_data); 2040 - return -ENODEV; 2040 + rc = -ENODEV; 2041 + goto unlock; 2041 2042 } 2042 2043 2043 2044 EXPECT_BEGIN(KERN_INFO, ··· 2057 2056 EXPECT_END(KERN_INFO, 2058 2057 "Duplicate name in testcase-data, renamed to \"duplicate-name#1\""); 2059 2058 2059 + unlock: 2060 2060 of_overlay_mutex_unlock(); 2061 2061 2062 - return 0; 2062 + return rc; 2063 2063 } 2064 2064 2065 2065 #ifdef CONFIG_OF_OVERLAY