Merge 28962ec595 ("virtio_console: validate max_nr_ports before trying to use it") into android-mainline

Steps on the way to 5.16-rc1

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I41a68beb0e435043975a501b238ce713a41b04c5
This commit is contained in:
Greg Kroah-Hartman
2021-11-14 12:49:05 +01:00
2 changed files with 10 additions and 1 deletions

View File

@@ -572,7 +572,7 @@ static int init_vq(struct virtio_blk *vblk)
if (err)
num_vqs = 1;
if (!err && !num_vqs) {
dev_err(&vdev->dev, "MQ advertisted but zero queues reported\n");
dev_err(&vdev->dev, "MQ advertised but zero queues reported\n");
return -EINVAL;
}

View File

@@ -28,6 +28,7 @@
#include "../tty/hvc/hvc_console.h"
#define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC)
#define VIRTCONS_MAX_PORTS 0x8000
/*
* This is a global struct for storing common data for all the devices
@@ -2036,6 +2037,14 @@ static int virtcons_probe(struct virtio_device *vdev)
virtio_cread_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT,
struct virtio_console_config, max_nr_ports,
&portdev->max_nr_ports) == 0) {
if (portdev->max_nr_ports == 0 ||
portdev->max_nr_ports > VIRTCONS_MAX_PORTS) {
dev_err(&vdev->dev,
"Invalidate max_nr_ports %d",
portdev->max_nr_ports);
err = -EINVAL;
goto free;
}
multiport = true;
}