git: e1e4790d7de2 - main - bhyve: rfb: do not destroy a mutex that was never initialized

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 16:49:58 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=e1e4790d7de20f28683031ac806adb6abbafe867

commit e1e4790d7de20f28683031ac806adb6abbafe867
Author:     Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2026-11-11 15:05:50 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-11 16:49:43 +0000

    bhyve: rfb: do not destroy a mutex that was never initialized
    
    rfb_init()'s error path tests pixfmt_mtx against NULL, which only
    compiles where pthread_mutex_t is a pointer, and destroys it.  Every
    jump to that label is before the mutex is initialized, so there is
    nothing to destroy.  The test and the destroy came in with the
    SetPixelFormat support (D46402).
    
    Signed-off-by:  Wanpeng Qian <wanpengqian@gmail.com>
    
    Fixes:          dda0f9837b1c ("bhyve: support noVNC SetPixelFormat request")
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   keelos.dev
    Differential Revision:  https://reviews.freebsd.org/D61425
---
 usr.sbin/bhyve/rfb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c
index 265c95ace0a9..5c6d437e6a8d 100644
--- a/usr.sbin/bhyve/rfb.c
+++ b/usr.sbin/bhyve/rfb.c
@@ -1463,8 +1463,6 @@ rfb_init(sa_family_t family, const char *hostname, int port, int wait,
 	return (0);
 
  error:
-	if (rc->pixfmt_mtx)
-		pthread_mutex_destroy(&rc->pixfmt_mtx);
 	if (ai != NULL) {
 		assert(family != AF_UNIX);
 		freeaddrinfo(ai);