virtio/balloon: verify device has config space
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 12 Jan 2015 14:23:37 +0000 (16:23 +0200)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 21 Jan 2015 05:58:48 +0000 (16:28 +1030)
Some devices might not implement config space access
(e.g. remoteproc used not to - before 3.9).
virtio/balloon 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>
drivers/virtio/virtio_balloon.c

index 50c5f42d7a9f3010c5f12275b7fd540161900392..3176ea4028a83c26b03415d9202a8343ed66c512 100644 (file)
@@ -466,6 +466,12 @@ static int virtballoon_probe(struct virtio_device *vdev)
        struct virtio_balloon *vb;
        int err;
 
+       if (!vdev->config->get) {
+               dev_err(&vdev->dev, "%s failure: config access disabled\n",
+                       __func__);
+               return -EINVAL;
+       }
+
        vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
        if (!vb) {
                err = -ENOMEM;