From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 353BA4ED1A9; Thu, 17 Sep 2026 15:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789660142; cv=none; b=jGkX44kHQT0wlOpPijpE3B+67t08QcJiCMYydx9X9c6G1YKp9Tde2nVF+CTLJIeCziPGqJxYPNcRa/bdNtuSpDbs5n8DuJRALxt+B+FCq4n/XcVngc5hBeYjZnm8Q/GTcOsgEetFSTP+9IHgO640dfXvHRZ07VcfF5LCSnHuwRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789660142; c=relaxed/simple; bh=SZP20Nwcs0fXgZSyRYRWQaR2xRW0+rBX6PCyTeg/SCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VELeFZe/yEZ7laZDGR/4w9P+HX6vUmW/TiuW3lU+jaTy9kpNdqIJP5quPe7n00adyoJvGK4FeUv9X9sdqQVuULM+IwvC2aGYAYxxD/XX1VkdATB+pZ6MGoaqBfV3qDSHgPWLrBzXDCCDobIlctB0vVGhRzAKC9Ml6wdkcengsR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QwtEHgAC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QwtEHgAC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A77301F00899; Thu, 17 Sep 2026 15:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789660136; bh=CvO/KwCU9MZYtQ52Ljf2ADGer6HSSQnjZsfvqVbARzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QwtEHgACdZssola3KN8T7VqBmlYKq2Rrui922ieYhQmw9xIjoKWTd1aAMtu6BXagB pvW4SMhwxlMsOo236qTDG0ir0IwdKIGkts3DOEXiw4qqgCANOkDANOhmzYlPIp+Hfs pvN9F1CjCmNiW9ESYhvI7ZP9MvaLCT93rPZSrLJM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiong Weimin , "Michael S. Tsirkin" Subject: [PATCH 7.2 490/733] virtio_mmio: disable IRQ wake before free_irq Date: Thu, 17 Sep 2026 16:13:18 +0100 Message-ID: <20260917151404.263949003@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151350.597953846@linuxfoundation.org> References: <20260917151350.597953846@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiong Weimin commit d14d693adb055e98ca705822ba6daebc18602d9a upstream. When the DT node has "wakeup-source", vm_find_vqs() calls enable_irq_wake() on the shared IRQ, but vm_del_vqs() freed that IRQ without a matching disable_irq_wake(). That leaves a wake reference behind and can warn on later free_irq()/request_irq() cycles. Record whether enable_irq_wake() succeeded, and disable it in vm_del_vqs() before free_irq(). Fixes: 02213273f72a ("virtio_mmio: add support to set IRQ of a virtio device as wakeup source") Cc: stable@vger.kernel.org Signed-off-by: Xiong Weimin Signed-off-by: Michael S. Tsirkin Message-ID: <20260805032937.1606737-1-xiongweimin@kylinos.cn> Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_mmio.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -87,6 +87,9 @@ struct virtio_mmio_device { void __iomem *base; unsigned long version; + + /* True if enable_irq_wake() succeeded for the shared IRQ. */ + bool wake_irq_enabled; }; /* Configuration interface */ @@ -329,11 +332,17 @@ static void vm_del_vqs(struct virtio_dev { struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); struct virtqueue *vq, *n; + int irq = platform_get_irq(vm_dev->pdev, 0); list_for_each_entry_safe(vq, n, &vdev->vqs, list) vm_del_vq(vq); - free_irq(platform_get_irq(vm_dev->pdev, 0), vm_dev); + if (vm_dev->wake_irq_enabled) { + disable_irq_wake(irq); + vm_dev->wake_irq_enabled = false; + } + + free_irq(irq, vm_dev); } static void vm_synchronize_cbs(struct virtio_device *vdev) @@ -460,8 +469,9 @@ static int vm_find_vqs(struct virtio_dev if (err) return err; - if (of_property_read_bool(vm_dev->pdev->dev.of_node, "wakeup-source")) - enable_irq_wake(irq); + if (of_property_read_bool(vm_dev->pdev->dev.of_node, "wakeup-source") && + !enable_irq_wake(irq)) + vm_dev->wake_irq_enabled = true; for (i = 0; i < nvqs; ++i) { struct virtqueue_info *vqi = &vqs_info[i];