From nobody Sat Dec 28 10:10:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1719798698; cv=none; d=zohomail.com; s=zohoarc; b=UJKPdgrnBQkeYtlBoMrAIedAwkGRVMHL3o79405DKNcsbGpLvwXwGk2mSS0GXwTjdLNc5lx64Hj3p85u/JNgH0evm+o1Nbd+OVCtVFcIJZ9HE0gmK80nT/EEVpmgxdfIiK5m+jXTTERZe8wAPZuJ/kRtSpzXDj8p4B346yYmTFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719798698; h=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=KejaszIeSBvJOL/BUsYhvbFJQdL5vX1a32+hzQAZnXI=; b=lHV/zzZpMv7pG+1MdHML2ThJhg2A2QGw0jLcxuYBGhzemAC95jpAVLtZ7+6odLltE5tu/905xkCZ5iY/pxVU076uTmOf1eIwe6qDd2IlStmnNl68cnXTThUIvpXh8aojKpTFpR/RM+cq25Mg6muJA6CHOTnzqckBDWxfkc5puRk= 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+importer2=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 1719798698578603.8154571973945; Sun, 30 Jun 2024 18:51:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sO6Bu-0007CB-5K; Sun, 30 Jun 2024 21:50:50 -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 1sO6Br-0007BT-PH for qemu-devel@nongnu.org; Sun, 30 Jun 2024 21:50:48 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sO6Bq-0002Vo-5m for qemu-devel@nongnu.org; Sun, 30 Jun 2024 21:50:47 -0400 Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2024 18:50:45 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.127]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2024 18:50:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719798646; x=1751334646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QFoo/oW2gy364eaSg+HnP/vfvqJKypfoae1HGt5KJYE=; b=KoLQk2MunXUAur89nzaPOKkSiPfKsfnopR4/corg9hR9OhpfEzYBcNIS uHJAQ9O5KvjJAksPdvRCgqrOxFwaWdtTqn/Qm+l1Ls399gjroXS78uY5a 5WvuMHXHUCJtK5FVdttOOMsw9BCzmlc+9Pm8QtgjVFzmhijt5j7Nk534L rVB3ug66E/2EVkDLg1o98CTO0Q8F3Q+MzsjEtelH+72zCi3SvlUOoDSN/ lwejrZ8MFsiDErtBNmFfqGwQKv254i6CflQbmlzWkkDZmoQhNWT+UBLOo J3vhsZnZhME/K8kQifZb2RUGx70wvSBzuzMWo2/HVecSLBzKeAnSu3Jpk Q==; X-CSE-ConnectionGUID: 0TtBveQMQtCyQreiuM+ilQ== X-CSE-MsgGUID: BBWVckAqT3qlHYINY8l/JA== X-IronPort-AV: E=McAfee;i="6700,10204,11119"; a="42319509" X-IronPort-AV: E=Sophos;i="6.09,175,1716274800"; d="scan'208";a="42319509" X-CSE-ConnectionGUID: TtqF1Mw4TXa14+KwDs9ylg== X-CSE-MsgGUID: +cuiyYa9T3iihRkjHASGOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,175,1716274800"; d="scan'208";a="45331373" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, marcandre.lureau@redhat.com, kraxel@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 1/2] vfio/display: Fix potential memleak of edid info Date: Mon, 1 Jul 2024 09:48:08 +0800 Message-Id: <20240701014809.255682-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701014809.255682-1-zhenzhong.duan@intel.com> References: <20240701014809.255682-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.7; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1719798700154100003 Content-Type: text/plain; charset="utf-8" EDID related device region info is leaked in vfio_display_edid_init() error path and VFIODisplay destroying path. Fixes: 08479114b0de ("vfio/display: add edid support.") Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/vfio/display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 661e921616..9c57fd3888 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -171,7 +171,9 @@ static void vfio_display_edid_init(VFIOPCIDevice *vdev) =20 err: trace_vfio_display_edid_write_error(); + g_free(dpy->edid_info); g_free(dpy->edid_regs); + dpy->edid_info =3D NULL; dpy->edid_regs =3D NULL; return; } @@ -182,6 +184,7 @@ static void vfio_display_edid_exit(VFIODisplay *dpy) return; } =20 + g_free(dpy->edid_info); g_free(dpy->edid_regs); g_free(dpy->edid_blob); timer_free(dpy->edid_link_timer); --=20 2.34.1 From nobody Sat Dec 28 10:10:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1719798702; cv=none; d=zohomail.com; s=zohoarc; b=N0wm5B3dGbQrholTfRq72e0QxRJT3l2PEL9teElJmfvuY1v2oiDoY2EotPTJu/gOZ/ZN9lkKFC1WyWnmHxtUl5MNXL2yrD70bY/lXvZU6CBrQHuowXS6aiT3a+d2VpZjWOOyAzqcbRYkKJSAD5BaHb3aKatxrUljyfwRr55SwyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719798702; 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=PG9iLMg4sqUtI8KWX3w0cO+I8ApjVGsXYm9IZCDmfOg=; b=GsPZQJ+L9gyUTq2BIHHnZGDD39o/pZ55U5IJGgj1I9OXpqZHeMWguYaid/fNZl0lB1NIxs8WM0U+JInN62NxjqMoJkeIaEjhFK89Y9s+2eHkZlJWU3/tD+jlbRFykFv2QrpbCOefxXhL/MPAxCrTJemsdDUusJfw0K5pY4ge0DI= 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+importer2=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 1719798702652126.65621874617511; Sun, 30 Jun 2024 18:51:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sO6Bv-0007Cq-Nt; Sun, 30 Jun 2024 21:50:51 -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 1sO6Bt-0007Bm-IB for qemu-devel@nongnu.org; Sun, 30 Jun 2024 21:50:49 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sO6Br-0002VV-VF for qemu-devel@nongnu.org; Sun, 30 Jun 2024 21:50:49 -0400 Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2024 18:50:47 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.127]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2024 18:50:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719798648; x=1751334648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bWftXaq3bJu5ofRw1ucpxYLjBnLtyLlRDFZLb1uv9AE=; b=hwS465sxTSxnDYPUU4NdeXJMktNuffq10fAr8+5MxXuQP0KOjb3QyhKf Cfg63+zS9HMtjv9nDzLakHbi5Q34a8ob6UBT+wlLivKKwBbmMw1Ks9eyz L///xj0hyVv4jtjazmlo+YLdplWG0eV2or6puDYBUz/ZG9QC5yxp49U+V nXOvR7FiG77dEnYQLsuDqoeXMEbv3llAJENBB7LXkPfZdXtKCurWbSr6L b8PCYjrq4+/wXmnGgvNrkt/lVM+fee/s/DhT+TpCUcWMaf2tzy1rHUB2P CXLC6wT5+6wI9XPu7+aI+9DIqyBf5bjArw70cYs0B2lZGktB3NzBgeIgE Q==; X-CSE-ConnectionGUID: Y1T7DAshRG+RQdR6jUsO0g== X-CSE-MsgGUID: 03clJ36tTCShuPfBMv0WWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11119"; a="42319512" X-IronPort-AV: E=Sophos;i="6.09,175,1716274800"; d="scan'208";a="42319512" X-CSE-ConnectionGUID: NzAXh+XsSeyEIqHVRQj7qg== X-CSE-MsgGUID: E9lCSA0zQJO4bM5xJvnAaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,175,1716274800"; d="scan'208";a="45331382" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, marcandre.lureau@redhat.com, kraxel@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 2/2] vfio/display: Fix vfio_display_edid_init() error path Date: Mon, 1 Jul 2024 09:48:09 +0800 Message-Id: <20240701014809.255682-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701014809.255682-1-zhenzhong.duan@intel.com> References: <20240701014809.255682-1-zhenzhong.duan@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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.7; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1719798704168100003 vfio_display_edid_init() can fail for many reasons and return silently. It would be good to report the error. Old mdev driver may not support vfio edid region and we allow to go through in this case. vfio_display_edid_update() isn't changed because it can be called at runtime when UI changes (i.e. window resize). Fixes: 08479114b0de ("vfio/display: add edid support.") Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/vfio/display.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 9c57fd3888..ea87830fe0 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -124,7 +124,7 @@ static void vfio_display_edid_ui_info(void *opaque, uin= t32_t idx, } } =20 -static void vfio_display_edid_init(VFIOPCIDevice *vdev) +static bool vfio_display_edid_init(VFIOPCIDevice *vdev, Error **errp) { VFIODisplay *dpy =3D vdev->dpy; int fd =3D vdev->vbasedev.fd; @@ -135,7 +135,8 @@ static void vfio_display_edid_init(VFIOPCIDevice *vdev) VFIO_REGION_SUBTYPE_GFX_EDID, &dpy->edid_info); if (ret) { - return; + /* Failed to get GFX edid info, allow to go through without edid. = */ + return true; } =20 trace_vfio_display_edid_available(); @@ -167,15 +168,16 @@ static void vfio_display_edid_init(VFIOPCIDevice *vde= v) vfio_display_edid_link_up, vdev); =20 vfio_display_edid_update(vdev, true, 0, 0); - return; + return true; =20 err: + error_setg(errp, "vfio: failed to read GFX edid field"); trace_vfio_display_edid_write_error(); g_free(dpy->edid_info); g_free(dpy->edid_regs); dpy->edid_info =3D NULL; dpy->edid_regs =3D NULL; - return; + return false; } =20 static void vfio_display_edid_exit(VFIODisplay *dpy) @@ -368,8 +370,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vde= v, Error **errp) return false; } } - vfio_display_edid_init(vdev); - return true; + return vfio_display_edid_init(vdev, errp); } =20 static void vfio_display_dmabuf_exit(VFIODisplay *dpy) --=20 2.34.1