fix mutex unlock if open fails

This commit is contained in:
Frank Rolsted Jensen
2023-10-13 09:21:25 +02:00
parent 015da8a55e
commit 2f0cea6f73
+4 -1
View File
@@ -427,7 +427,6 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
int res; int res;
int n; int n;
pthread_mutex_lock(&access_lock);
tty_cli = calloc(1, sizeof(ttynvt_cli_t)); tty_cli = calloc(1, sizeof(ttynvt_cli_t));
if (!tty_cli) if (!tty_cli)
@@ -435,12 +434,16 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
fuse_reply_err(req, ENOMEM); fuse_reply_err(req, ENOMEM);
return; return;
} }
pthread_mutex_lock(&access_lock);
if (tty == NULL) if (tty == NULL)
tty = _ttynvt_ctx_create(); tty = _ttynvt_ctx_create();
if (!tty) if (!tty)
{ {
fuse_reply_err(req, ENOMEM); fuse_reply_err(req, ENOMEM);
free(tty_cli); free(tty_cli);
pthread_mutex_unlock(&access_lock);
return; return;
} }