From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F0CB01E282B; Tue, 15 Oct 2024 13:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728998429; cv=none; b=gM1Iv9g2fCuwRzClPYq3fjrZKtue8OUIst1Aoie4TGUFgNw6524n/rS3LvWfyDq7i/ZBEV8liGmPtA9H7P9i4BkNSdYDr3rN0rdNDGnzmdcWIMxGZVMKTI4ZQxsk8UhpLzUKlNuxvKwpuJVYQaBziB1nl57yiQf+8Pbju5x2t98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728998429; c=relaxed/simple; bh=/HXXJLAOVujbDiZPuYlENCqp+Brtp+VPHuxLo6A50yA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GBqgu1AUYyRvLm6QQMKm9rwKJarI77woo2vwegoZArxqwyaNrYmVKKSmmGFUVgDer4/SLmTYkrkhVwWzRQ+W7VjJPAVfGvrSPrfRoBd86bAwDkD9G5cLUrIH3NbFonBj7fEr2gBJ+d9lDTE4SUbkLiB5BL2TPqaQpIU9GpxKd+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oNTelrgy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oNTelrgy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60932C4CEC6; Tue, 15 Oct 2024 13:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728998428; bh=/HXXJLAOVujbDiZPuYlENCqp+Brtp+VPHuxLo6A50yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNTelrgymy0U6QMcRod9mRjkke0rkAFpcPNwbB/XtIEF+2IWMFaze3TJartGbRqor +p6BHxTRB+hcuX/hCheqxnGDWHskIRTx4kiMCaIXfHAVjJe1ByeM3R4Bx5UTpE8fCC Be6xt/GyO/9noEstmra3JHdb9139E5VSPfzSVUdo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 5.10 443/518] virtio_console: fix misc probe bugs Date: Tue, 15 Oct 2024 14:45:47 +0200 Message-ID: <20241015123934.102771331@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015123916.821186887@linuxfoundation.org> References: <20241015123916.821186887@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael S. Tsirkin [ Upstream commit b9efbe2b8f0177fa97bfab290d60858900aa196b ] This fixes the following issue discovered by code review: after vqs have been created, a buggy device can send an interrupt. A control vq callback will then try to schedule control_work which has not been initialized yet. Similarly for config interrupt. Further, in and out vq callbacks invoke find_port_by_vq which attempts to take ports_lock which also has not been initialized. To fix, init all locks and work before creating vqs. Message-ID: Fixes: 17634ba25544 ("virtio: console: Add a new MULTIPORT feature, support for generic ports") Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/char/virtio_console.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 6d361420ffe82..1734b4341585c 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2049,25 +2049,27 @@ static int virtcons_probe(struct virtio_device *vdev) multiport = true; } - err = init_vqs(portdev); - if (err < 0) { - dev_err(&vdev->dev, "Error %d initializing vqs\n", err); - goto free_chrdev; - } - spin_lock_init(&portdev->ports_lock); INIT_LIST_HEAD(&portdev->ports); INIT_LIST_HEAD(&portdev->list); - virtio_device_ready(portdev->vdev); - INIT_WORK(&portdev->config_work, &config_work_handler); INIT_WORK(&portdev->control_work, &control_work_handler); if (multiport) { spin_lock_init(&portdev->c_ivq_lock); spin_lock_init(&portdev->c_ovq_lock); + } + err = init_vqs(portdev); + if (err < 0) { + dev_err(&vdev->dev, "Error %d initializing vqs\n", err); + goto free_chrdev; + } + + virtio_device_ready(portdev->vdev); + + if (multiport) { err = fill_queue(portdev->c_ivq, &portdev->c_ivq_lock); if (err < 0) { dev_err(&vdev->dev, -- 2.43.0