]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.177/s390-virtio-handle-find-on-invalid-queue-gracefully.patch
Linux 4.4.177
[thirdparty/kernel/stable-queue.git] / releases / 4.4.177 / s390-virtio-handle-find-on-invalid-queue-gracefully.patch
CommitLineData
fd02d56f
GKH
1From 3438b2c039b4bf26881786a1f3450f016d66ad11 Mon Sep 17 00:00:00 2001
2From: Halil Pasic <pasic@linux.ibm.com>
3Date: Mon, 21 Jan 2019 13:19:43 +0100
4Subject: s390/virtio: handle find on invalid queue gracefully
5
6From: Halil Pasic <pasic@linux.ibm.com>
7
8commit 3438b2c039b4bf26881786a1f3450f016d66ad11 upstream.
9
10A queue with a capacity of zero is clearly not a valid virtio queue.
11Some emulators report zero queue size if queried with an invalid queue
12index. Instead of crashing in this case let us just return -ENOENT. To
13make that work properly, let us fix the notifier cleanup logic as well.
14
15Cc: stable@vger.kernel.org
16Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
17Signed-off-by: Cornelia Huck <cohuck@redhat.com>
18Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 drivers/s390/virtio/virtio_ccw.c | 4 +++-
23 1 file changed, 3 insertions(+), 1 deletion(-)
24
25--- a/drivers/s390/virtio/virtio_ccw.c
26+++ b/drivers/s390/virtio/virtio_ccw.c
27@@ -283,6 +283,8 @@ static void virtio_ccw_drop_indicators(s
28 {
29 struct virtio_ccw_vq_info *info;
30
31+ if (!vcdev->airq_info)
32+ return;
33 list_for_each_entry(info, &vcdev->virtqueues, node)
34 drop_airq_indicator(info->vq, vcdev->airq_info);
35 }
36@@ -423,7 +425,7 @@ static int virtio_ccw_read_vq_conf(struc
37 ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_READ_VQ_CONF);
38 if (ret)
39 return ret;
40- return vcdev->config_block->num;
41+ return vcdev->config_block->num ?: -ENOENT;
42 }
43
44 static void virtio_ccw_del_vq(struct virtqueue *vq, struct ccw1 *ccw)