From 2f0cea6f7330532d0939127c4959873813c2f963 Mon Sep 17 00:00:00 2001 From: Frank Rolsted Jensen Date: Fri, 13 Oct 2023 09:21:25 +0200 Subject: [PATCH] fix mutex unlock if open fails --- src/ttynvt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ttynvt.c b/src/ttynvt.c index 8914874..38b7781 100644 --- a/src/ttynvt.c +++ b/src/ttynvt.c @@ -427,7 +427,6 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info) int res; int n; - pthread_mutex_lock(&access_lock); tty_cli = calloc(1, sizeof(ttynvt_cli_t)); 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); return; } + + pthread_mutex_lock(&access_lock); + if (tty == NULL) tty = _ttynvt_ctx_create(); if (!tty) { fuse_reply_err(req, ENOMEM); free(tty_cli); + pthread_mutex_unlock(&access_lock); return; }