This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit dff81756cf86cb974134e82f713d2fbd609f050b
Author: chao an <anc...@xiaomi.com>
AuthorDate: Sun Nov 20 22:28:39 2022 +0800

    drivers/regulator_rpmsg: destroy nxsem properly
    
    Signed-off-by: chao an <anc...@xiaomi.com>
---
 drivers/power/supply/regulator_rpmsg.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/power/supply/regulator_rpmsg.c 
b/drivers/power/supply/regulator_rpmsg.c
index 03c2785bd8..ccd4edb0f7 100644
--- a/drivers/power/supply/regulator_rpmsg.c
+++ b/drivers/power/supply/regulator_rpmsg.c
@@ -495,18 +495,17 @@ static int regulator_rpmsg_sendrecv(FAR struct 
rpmsg_endpoint *ept,
   msg->cookie = (uintptr_t)&cookie;
 
   ret = rpmsg_send_nocopy(ept, msg, len);
-  if (ret < 0)
+  if (ret >= 0)
     {
-      return ret;
-    }
-
-  ret = nxsem_wait_uninterruptible(&cookie.sem);
-  if (ret < 0)
-    {
-      return ret;
+      ret = nxsem_wait_uninterruptible(&cookie.sem);
+      if (ret >= 0)
+        {
+          ret = cookie.result;
+        }
     }
 
-  return cookie.result;
+  nxsem_destroy(&cookie.sem);
+  return ret;
 }
 
 static int regulator_rpmsg_enable(FAR struct regulator_dev_s *rdev)

Reply via email to