From: Michael S. Tsirkin <mst@redhat.com>
Date: Mon, 12 Jan 2015 14:23:37 +0000 (+0200)
Subject: virtio/console: verify device has config space
X-Git-Tag: firefly_0821_release~176^2~2282^2~76
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=011f0e7a6944855436fb29c7a7e6c3c89c95f8fb;p=firefly-linux-kernel-4.4.55.git

virtio/console: verify device has config space

Some devices might not implement config space access
(e.g. remoteproc used not to - before 3.9).
virtio/console needs config space access so make it
fail gracefully if not there.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index de03df9dd7c9..26afb56a8073 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1986,6 +1986,12 @@ static int virtcons_probe(struct virtio_device *vdev)
 	bool multiport;
 	bool early = early_put_chars != NULL;
 
+	if (!vdev->config->get) {
+		dev_err(&vdev->dev, "%s failure: config access disabled\n",
+			__func__);
+		return -EINVAL;
+	}
+
 	/* Ensure to read early_put_chars now */
 	barrier();