From 5457a9a450b0dbb3ab36cd98a4b76dddccfd149d Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Thu, 3 Feb 2022 11:48:44 +0800 Subject: [PATCH] serial/pty: fix the lock handling Signed-off-by: chao.an --- drivers/serial/pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index ca238d9fc9..d6be3526eb 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -298,6 +298,7 @@ static int pty_open(FAR struct file *filep) ret = nxsem_wait(&devpair->pp_slavesem); if (ret < 0) { + sched_unlock(); return ret; } @@ -308,6 +309,7 @@ static int pty_open(FAR struct file *filep) ret = pty_semtake(devpair); if (ret < 0) { + sched_unlock(); return ret; } @@ -335,7 +337,7 @@ static int pty_open(FAR struct file *filep) ret = pty_semtake(devpair); if (ret < 0) { - goto errout_with_sem; + return ret; } } @@ -362,7 +364,6 @@ static int pty_open(FAR struct file *filep) ret = OK; } -errout_with_sem: pty_semgive(devpair); return ret; }