From patchwork Fri Apr 19 18:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13636747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9C89C04FF6 for ; Fri, 19 Apr 2024 19:05:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxtX0-0005tB-Rt; Fri, 19 Apr 2024 15:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxtWy-0005sb-Ux for qemu-devel@nongnu.org; Fri, 19 Apr 2024 15:04:17 -0400 Received: from mgamail.intel.com ([192.198.163.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxtWx-0004Dj-5I for qemu-devel@nongnu.org; Fri, 19 Apr 2024 15:04:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713553455; x=1745089455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=67NgeQ/kFsPNIg8m3af1zHaTrIuCCnTfBkPGdpoYPQc=; b=EPG464vtFn0KXoEMlSJE1SxnJjmRgIT9dierlNQHPbGgXQwONNXljVh5 iaqnu2KWLxxOsXq0qUbNbBwf7JJVCBMH2K3wEvc4KJ1PDuhDOhvUEkZ+b U1VYY1eqSfPDvIaDAhGUUJH8T/25qEbVtmceRPUX+lq0wLFa6gUY9TKN4 9f/d+AT6GtSIBTcIhuisi18n2JXsW2w27kIMNflX7XHIqJpD9Ev1C3acM /De3drpf2fg595cv6Es2g05zuMGS6ilN1TuyIDEi609Genkj8TnkQ711g 28w0BsgekDhcDaPD5u6eTO19inYsJlYTyq9hi7cl57SC78ilytp14RHlr w==; X-CSE-ConnectionGUID: iG1j5A+XS3SO0UpGK5MIGg== X-CSE-MsgGUID: SQ0nMwBGSZiaq57lM4c/Rg== X-IronPort-AV: E=McAfee;i="6600,9927,11049"; a="20564985" X-IronPort-AV: E=Sophos;i="6.07,214,1708416000"; d="scan'208";a="20564985" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2024 12:04:07 -0700 X-CSE-ConnectionGUID: silkh8tkTJymh0GZtsDDtA== X-CSE-MsgGUID: 1jItd2arQvShSbYioY4Zvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,214,1708416000"; d="scan'208";a="54346785" Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by orviesa002.jf.intel.com with ESMTP; 19 Apr 2024 12:04:07 -0700 From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v8 1/6] ui/gtk: Check if fence_fd is equal to or greater than 0 Date: Fri, 19 Apr 2024 11:59:47 -0700 Message-Id: <20240419185952.991930-2-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419185952.991930-1-dongwon.kim@intel.com> References: <20240419185952.991930-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.198.163.10; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -66 X-Spam_score: -6.7 X-Spam_bar: ------ X-Spam_report: (-6.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.313, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Dongwon Kim 'fence_fd' needs to be validated always before being referenced And the passing condition should include '== 0' as 0 is a valid value for the file descriptor. Suggested-by: Marc-André Lureau Cc: Philippe Mathieu-Daudé Cc: Daniel P. Berrangé Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk-egl.c | 2 +- ui/gtk-gl-area.c | 2 +- ui/gtk.c | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 3af5ac5bcf..955234429d 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -99,7 +99,7 @@ void gd_egl_draw(VirtualConsole *vc) #ifdef CONFIG_GBM if (dmabuf) { egl_dmabuf_create_fence(dmabuf); - if (dmabuf->fence_fd > 0) { + if (dmabuf->fence_fd >= 0) { qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc); return; } diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 52dcac161e..7fffd0544e 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -86,7 +86,7 @@ void gd_gl_area_draw(VirtualConsole *vc) #ifdef CONFIG_GBM if (dmabuf) { egl_dmabuf_create_fence(dmabuf); - if (dmabuf->fence_fd > 0) { + if (dmabuf->fence_fd >= 0) { qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc); return; } diff --git a/ui/gtk.c b/ui/gtk.c index 810d7fc796..7819a86321 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -597,10 +597,12 @@ void gd_hw_gl_flushed(void *vcon) VirtualConsole *vc = vcon; QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf; - qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); - close(dmabuf->fence_fd); - dmabuf->fence_fd = -1; - graphic_hw_gl_block(vc->gfx.dcl.con, false); + if (dmabuf->fence_fd >= 0) { + qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); + close(dmabuf->fence_fd); + dmabuf->fence_fd = -1; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + } } /** DisplayState Callbacks (opengl version) **/