diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-04 19:20:27 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 15:32:32 +0100 |
commit | 5c609a5ef05d98e26778824ba84581fe5e400db6 (patch) | |
tree | 487da89e8ad7ef9d3bcb485ae877518f1669e18b /drivers/virtio/virtio.c | |
parent | virtio_ccw: legacy: don't negotiate rev 1/features (diff) | |
download | linux-5c609a5ef05d98e26778824ba84581fe5e400db6.tar.xz linux-5c609a5ef05d98e26778824ba84581fe5e400db6.zip |
virtio: allow finalize_features to fail
This will make it easy for transports to validate features and return
failure.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r-- | drivers/virtio/virtio.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 224f85442f3f..e1673a511d17 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -212,7 +212,9 @@ static int virtio_dev_probe(struct device *_d) if (device_features & (1ULL << i)) __virtio_set_bit(dev, i); - dev->config->finalize_features(dev); + err = dev->config->finalize_features(dev); + if (err) + goto err; if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); @@ -354,6 +356,7 @@ EXPORT_SYMBOL_GPL(virtio_device_freeze); int virtio_device_restore(struct virtio_device *dev) { struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); + int ret; /* We always start by resetting the device, in case a previous * driver messed it up. */ @@ -373,14 +376,14 @@ int virtio_device_restore(struct virtio_device *dev) /* We have a driver! */ add_status(dev, VIRTIO_CONFIG_S_DRIVER); - dev->config->finalize_features(dev); + ret = dev->config->finalize_features(dev); + if (ret) + goto err; if (drv->restore) { - int ret = drv->restore(dev); - if (ret) { - add_status(dev, VIRTIO_CONFIG_S_FAILED); - return ret; - } + ret = drv->restore(dev); + if (ret) + goto err; } /* Finally, tell the device we're all set */ @@ -389,6 +392,10 @@ int virtio_device_restore(struct virtio_device *dev) virtio_config_enable(dev); return 0; + +err: + add_status(dev, VIRTIO_CONFIG_S_FAILED); + return ret; } EXPORT_SYMBOL_GPL(virtio_device_restore); #endif |