From nobody Sat Nov 15 16:32:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750924218; cv=none; d=zohomail.com; s=zohoarc; b=VmGA6IsnclJC0VTHbcPe7sxQh7zD7DXMzJrE9JVYxVWNf4kcQ58Nyg5HUayvKHjpOnQyBE4twn3Pdjhh5oOPyB3PQub80+L6gyGqVVC4eH5pZOpInefhcz2DCWTY9ANyp2WWRNdly2rB2bCjqTwM5CLbpRpmGT7Z+BMRiX4rFno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750924218; 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=ByhnffEcIoi804d7Url3PJ2rw+ryQ3F85UYi3x35kkM=; b=FFFRtS1S3kNwhYDjWNBbp/uIZq4A4eDZngtWQUxUCtlBKXnVwb02PwWznS1nwae5VZZWlSzTd7NxZyyfEp51XtmVt15PDh21tGLlYzXNZzNVyyEZ3t0pHPIc4PG2J7OgYXNk3mlS0FhhNbqAawbxG3INFx+eAoelI0k7ZgmbcTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750924218171545.8470089386103; Thu, 26 Jun 2025 00:50:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uUhJE-0004RC-4q; Thu, 26 Jun 2025 03:46:12 -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 1uUhJ4-0004Q3-Gk for qemu-devel@nongnu.org; Thu, 26 Jun 2025 03:46:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uUhIu-0001vt-0M for qemu-devel@nongnu.org; Thu, 26 Jun 2025 03:46:02 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-yQL7QovrM2SSC1pj_gLtPA-1; Thu, 26 Jun 2025 03:45:47 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B63D81808985; Thu, 26 Jun 2025 07:45:46 +0000 (UTC) Received: from corto.redhat.com (unknown [10.44.32.51]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C87C518002B0; Thu, 26 Jun 2025 07:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750923951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ByhnffEcIoi804d7Url3PJ2rw+ryQ3F85UYi3x35kkM=; b=hr6oBZkiBMnDfrTFvH2xur/uR5zsjzxbBV8P0U15fyRMimNZ5fgLDY4lkxOdQDCoBp3cjR WWxLuMyKIa4wCs4sxumHxY3a3m5fVvuceT0ZQbm31exIQzH5SU7pUi1CvWGdgh5VXO72zY j8wbjp0EdWD/3t9LPkt/soRlsQ4EXgA= X-MC-Unique: yQL7QovrM2SSC1pj_gLtPA-1 X-Mimecast-MFC-AGG-ID: yQL7QovrM2SSC1pj_gLtPA_1750923946 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Zhenzhong Duan , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 05/25] vfio/container: Fix SIGSEGV when open container file fails Date: Thu, 26 Jun 2025 09:45:09 +0200 Message-ID: <20250626074529.1384114-6-clg@redhat.com> In-Reply-To: <20250626074529.1384114-1-clg@redhat.com> References: <20250626074529.1384114-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1750924220166116600 From: Zhenzhong Duan When open /dev/vfio/vfio fails, SIGSEGV triggers because vfio_listener_unregister() doesn't support a NULL bcontainer pointer. Fixes: a1f267a7d4d9 ("vfio/container: reform vfio_container_connect cleanup= ") Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Link: https://lore.kernel.org/qemu-devel/20250623102235.94877-2-zhenzhong.d= uan@intel.com Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 3e8d645ebbd7b13c55625f38f4250670a63df124..2853f6f08b5d3f199b7f2c22de8= 84ec6b57279ce 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -710,7 +710,9 @@ static bool vfio_container_connect(VFIOGroup *group, Ad= dressSpace *as, return true; =20 fail: - vfio_listener_unregister(bcontainer); + if (new_container) { + vfio_listener_unregister(bcontainer); + } =20 if (group_was_added) { vfio_container_group_del(container, group); --=20 2.49.0