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 3E0721DF721; Wed, 6 Nov 2024 12:18:00 +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=1730895480; cv=none; b=vFFsVEWTQMw3WzbGkEZJDXuB7Wz6/5n2xTu0pE7bn9WY6KFPuXi8izJrFreLAmO7kkIVDPFzID1h61SEy1Gk9RHQpLstUf6+ACA3FrxQQ8FQzGKCrheVMIuhM6WKtq6IVqiDlKq9bw3ZdW3tmRf0uP9NlSX6X0OVx25d6T1iD2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730895480; c=relaxed/simple; bh=qxLJPgHRRo/7mHsPtgY4YepUckG0SdbfbMrXQb9w6aM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JV090ZT66BrNudcsTj+D1gKbCVRX77ghDLJG9nmOpxvV2pTsDiQl84qSU3btKYPqY2Bh4iWQkV4Kjl8n9h3cKu0OU+g91jlO4Y/jXfw0F+rZclaTmoPobt1hkVneBOJIVXwS+Qmi2saG0KPvhmGP2wJqpTp+SP3w0GKtcerD1xg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aljzVAZx; 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="aljzVAZx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3CB4C4CECD; Wed, 6 Nov 2024 12:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730895480; bh=qxLJPgHRRo/7mHsPtgY4YepUckG0SdbfbMrXQb9w6aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aljzVAZxp+uK3hDk2h2Yff6yS3r47JyqNEVDrMzvrBU4uYXAdGSedH9fuTJ4puCT+ M82ta+VuZNx3NxKgo1MIfXE/M3niJKHJhwxDkUG/NZhOA8DHnwfGfF6LBMV2dlS1uD Wy9ke2jQIMLKcApe0W4e+H2I853y1zPDISKdUE+8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 4.19 232/350] virtio_console: fix misc probe bugs Date: Wed, 6 Nov 2024 13:02:40 +0100 Message-ID: <20241106120326.703705266@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120320.865793091@linuxfoundation.org> References: <20241106120320.865793091@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 4.19-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 d3937d6904000..ad9e266652607 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2075,25 +2075,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