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 4446C2590 for ; Sun, 22 Jan 2023 15:20:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 990F9C433EF; Sun, 22 Jan 2023 15:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674400839; bh=1W7Sxg3m3FAirHvv7eCwJQaeygqaPzmEqsB+Q9Q+2vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcqjDd9jf2JKlz6XrA7bi9aKblwBffvnHJrAcD7W5FYNtExuQtpPqdcEokDPzTEcm 8p+R1NSiQA/K2Mc2CnWF4UqYQxDycJAZtbLWNqCcTtSfTcjRa+DsvmN1FnXEo6MvhX i29fJugdDX0xk0peRStEOkYeVh89vmP2pdGDLl6k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Angus Chen , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 6.1 011/193] virtio_pci: modify ENOENT to EINVAL Date: Sun, 22 Jan 2023 16:02:20 +0100 Message-Id: <20230122150246.889255915@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230122150246.321043584@linuxfoundation.org> References: <20230122150246.321043584@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Angus Chen [ Upstream commit b66ead2d0ecac00c3a06a6218af5411cb5fcb5d5 ] Virtio_crypto use max_data_queues+1 to setup vqs, we use vp_modern_get_num_queues to protect the vq range in setup_vq. We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq if common->num_queues is not set well,and it return -ENOENT. It is better to use -EINVAL instead. Signed-off-by: Angus Chen Message-Id: <20221101111655.1947-1-angus.chen@jaguarmicro.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/virtio/virtio_pci_modern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index c3b9f2761849..edf2e18014cd 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -303,7 +303,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, int err; if (index >= vp_modern_get_num_queues(mdev)) - return ERR_PTR(-ENOENT); + return ERR_PTR(-EINVAL); /* Check if queue is either not available or already active. */ num = vp_modern_get_queue_size(mdev, index); -- 2.35.1