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 38231E571; Mon, 14 Oct 2024 14:24:54 +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=1728915894; cv=none; b=Byw582KaZFwTfN/OvbUyeOo8DPn64CC9CFdd46Yf5UX8aqyL6Wa5AB7pqtuvM5q/xBAZaobxFhpYSlE9UelM6vcDhV57L2HDfRLa5tuB6gwLfHjjDTHj7fp5o45OeDObriGmZm6jUQlB0dWijVqyRTlS01brrE4HdyrPby1Sksg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728915894; c=relaxed/simple; bh=Ewk2xc/vsKEtwcjrNdA5M5P/KpxITXm40vCC4o3/4Zk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oiWhTeGBLPT6/HdqsSHgTPKVRK3G57OmOy4TGDpjvdS1puy7Y24AXjzI9qJfu0LHLKVpCV4dGFuqL2TIft5PFLXZ/btJqbjBLdWAfwOCKvTdoO6LXlOYGi9hpgICcMhJ5NuVBF5CKs5NiDm/NwBWhUfxRal5U2ztDatbMSmoZw4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JGAoehZg; 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="JGAoehZg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4823C4CEC3; Mon, 14 Oct 2024 14:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728915894; bh=Ewk2xc/vsKEtwcjrNdA5M5P/KpxITXm40vCC4o3/4Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JGAoehZgoc6U5dQpSgQVeDdsJbgQm+c7e2jziVrdYOIkAm8atV0kW2QamPK41e3xM mgnb3+UFqnBcwVvcxJiIdHMZmukRWNy/3kZ8c9dmzQJnkGszFhycGHpn1WF819x9j9 GLEoeiKGxe8K6v6xl4EH7neu+F5qIjj+bWk7hi+U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 6.11 009/214] virtio_console: fix misc probe bugs Date: Mon, 14 Oct 2024 16:17:52 +0200 Message-ID: <20241014141045.356730682@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141044.974962104@linuxfoundation.org> References: <20241014141044.974962104@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 6.11-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 de7d720d99fa9..bcb05fc44c998 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2007,25 +2007,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