From nobody Mon Nov 25 14:58:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715107480; cv=none; d=zohomail.com; s=zohoarc; b=fIsQ9PxCPTOLDZ52X1Jg+0eetwVNY9b+9fSLvRZHBGanB3/3zuwbqNA5wyB6rtHyGk3kBzikdYrEyvvRfnR+H+yQXddPyn+oxtxpZqptdwwUNYy2JB7sdXXU0lmtOVLAr2NnQSVA3Felc5LS1c1zBy2mDSz43DVkqfCakRDjBLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715107480; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YolEHL1ybiCAWqmLG2FtG18fRpZz2xkK5wlQtVrL0AE=; b=h6eHbfIbcT2sg9EJTg2R8DzBTS/JWCyw1U8TEFk9ANDXzyBbW/3KxtR1Y6fFyV7L4liMGHdqvyPasOk32jz5bc7Yt/XI0eyQWOVuEXl9dMHKC9cOFjdfYldVeK8rDIQsBy2Zd/nqdQbSX7e3XcaN/N6UDF8sTjMwVDcRpQBJNxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715107480861793.6120459147457; Tue, 7 May 2024 11:44:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4PmL-0005HB-Jo; Tue, 07 May 2024 14:43:05 -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 1s4PmJ-0005GR-Il for qemu-devel@nongnu.org; Tue, 07 May 2024 14:43:03 -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 1s4PmH-0005KM-PR for qemu-devel@nongnu.org; Tue, 07 May 2024 14:43:03 -0400 Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 11:42:55 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by orviesa006.jf.intel.com with ESMTP; 07 May 2024 11:42:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715107382; x=1746643382; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nM6lzy2LotgC5Bu0VnCCHRXLjwNoTw5whq2lSmAvlx4=; b=Qjk3lZt1lCg1muxoXAPCb7mD5H8xDLoWKCV3a9Kxr7CrI6PBAHcKSaEj kPYk9Pl21dE6ABAU0yJYz1XB6HCFUaVfmt0X2R0ApG62B1I2EkA/+REID Bs+Fj6R3M/cu8GeS39c1UvL2Ofk0VDhUuVZDqXy92gHpb9bRefKOXMdki HYlhqDWAQOWM+aYuH4EnTp1nPz6QMMZJbKKMgiajg2hrQK4wKUMiuLfPk Fta4baCsjyn2lB5q9c4wGd88JlMtbNjQ4lEEXYtUDBT86a9PDZx2nbDwN BAftyWrxKbY/GA1HoEXq+7qvRiIoy21C77cR3vFJck2SK6L5HNfeh8LTQ Q==; X-CSE-ConnectionGUID: vDbvCQQeS6SNJ25cfTA2tQ== X-CSE-MsgGUID: YyaxGJwQRv28PGEAiYNmqg== X-IronPort-AV: E=McAfee;i="6600,9927,11066"; a="22321488" X-IronPort-AV: E=Sophos;i="6.08,143,1712646000"; d="scan'208";a="22321488" X-CSE-ConnectionGUID: GrhvcwgdQ+ye3a2LvpbD3w== X-CSE-MsgGUID: 2+iOpaekSZGAFwFkV5oK1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,143,1712646000"; d="scan'208";a="29031354" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, philmd@linaro.org, berrange@redhat.com Subject: [PATCH v13 1/6] ui/gtk: Check if fence_fd is equal to or greater than 0 Date: Tue, 7 May 2024 11:37:52 -0700 Message-Id: <20240507183757.3383641-2-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507183757.3383641-1-dongwon.kim@intel.com> References: <20240507183757.3383641-1-dongwon.kim@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.10; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715107482965100003 From: Dongwon Kim 'fence_fd' needs to be validated always before being referenced And the passing condition should include '=3D=3D 0' as 0 is a valid value for the file descriptor. Suggested-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Cc: Philippe Mathieu-Daud=C3=A9 Cc: Daniel P. Berrang=C3=A9 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 >=3D 0) { qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NU= LL, 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 >=3D 0) { qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NU= LL, 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 =3D vcon; QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; =20 - qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); - close(dmabuf->fence_fd); - dmabuf->fence_fd =3D -1; - graphic_hw_gl_block(vc->gfx.dcl.con, false); + if (dmabuf->fence_fd >=3D 0) { + qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); + close(dmabuf->fence_fd); + dmabuf->fence_fd =3D -1; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + } } =20 /** DisplayState Callbacks (opengl version) **/ --=20 2.34.1