From nobody Wed Feb 11 04:06:00 2026 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664451263; cv=none; d=zohomail.com; s=zohoarc; b=EgayErd4anYsORpSOBa7F5XVjN4DxQloUWLuMlrPVvubKP1CuH2cJW8J8QdyA3NGJUtP4HKpUlSsqj1GCznZQdAEc6Oe28VSabAhN27qviC/47dzr1uHBaqPt50b5Sck8gXNEdn6P6Uhax6vHcabQs+jqynyWXFoT/SilU8NLUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664451263; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7VUhs4rAc5DdkL/r1kEvE47gIjm+3f12pZ7vfN+8Q1c=; b=menHZR4Kj/sJUAd/T9sIUvJvxdYuA8W22oFdh6Wjm7VM+5PcyFI2jT/hm7fodk4NScW2nK92HQl6kVVy4tusbaU1k1e3L1Wh/1IICYcx91GDGAdqjaTYHxAVInu1zbm3Wps0ZWlWN7rG8s/N/K+07jZNIR4nxtMKJABfNlUGUPY= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664451263153278.8825156948453; Thu, 29 Sep 2022 04:34:23 -0700 (PDT) Received: from localhost ([::1]:52976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odro6-0000pr-58 for importer@patchew.org; Thu, 29 Sep 2022 07:34:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odrMK-0001F7-Q7 for qemu-devel@nongnu.org; Thu, 29 Sep 2022 07:05:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odrMJ-0001yf-AJ for qemu-devel@nongnu.org; Thu, 29 Sep 2022 07:05:40 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-455-dKGnIhEsMviUouM0psuRiw-1; Thu, 29 Sep 2022 07:05:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 065701C05AC0; Thu, 29 Sep 2022 11:05:37 +0000 (UTC) Received: from localhost (unknown [10.39.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2F834099B52; Thu, 29 Sep 2022 11:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664449538; 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=7VUhs4rAc5DdkL/r1kEvE47gIjm+3f12pZ7vfN+8Q1c=; b=jI/s6CZKj7aQGbr4KFTSvnoGmWoVBbNEXdxUiWo0Xj/WETsE0T+dR3iQfDndxRsV94XCeu 7tzjNS7WLoI+aaIH0unrvEyKIGhyPOBph233Mi6IMOFI4VagUvbH4dpTaST5K3+MbNaroH 7grWKP5RmjWJ4m//dP/vVhknLMbaznk= X-MC-Unique: dKGnIhEsMviUouM0psuRiw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Maksim Davydov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PULL 6/8] chardev: fix segfault in finalize Date: Thu, 29 Sep 2022 15:05:06 +0400 Message-Id: <20220929110508.1323529-7-marcandre.lureau@redhat.com> In-Reply-To: <20220929110508.1323529-1-marcandre.lureau@redhat.com> References: <20220929110508.1323529-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.08, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664451263984100001 From: Maksim Davydov If finalize chardev-msmouse or chardev-wctable is called immediately after init it cases QEMU to crash with segfault. This happens because of QTAILQ_REMOVE in qemu_input_handler_unregister tries to dereference NULL pointer. For instance, this error can be reproduced via `qom-list-properties` command. Signed-off-by: Maksim Davydov Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220825165247.33704-1-davydov-max@yandex-team.ru> --- chardev/msmouse.c | 4 +++- chardev/wctablet.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chardev/msmouse.c b/chardev/msmouse.c index 9006703023..ab8fe981d6 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -247,7 +247,9 @@ static void char_msmouse_finalize(Object *obj) { MouseChardev *mouse =3D MOUSE_CHARDEV(obj); =20 - qemu_input_handler_unregister(mouse->hs); + if (mouse->hs) { + qemu_input_handler_unregister(mouse->hs); + } fifo8_destroy(&mouse->outbuf); } =20 diff --git a/chardev/wctablet.c b/chardev/wctablet.c index e8b292c43c..43bdf6b608 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -319,7 +319,9 @@ static void wctablet_chr_finalize(Object *obj) { TabletChardev *tablet =3D WCTABLET_CHARDEV(obj); =20 - qemu_input_handler_unregister(tablet->hs); + if (tablet->hs) { + qemu_input_handler_unregister(tablet->hs); + } } =20 static void wctablet_chr_open(Chardev *chr, --=20 2.37.3