We previously tried to use device even if finalize_features failed, but that's wrong since driver and device are now out of sync. Fail probe if we detect failures during finalize_features.
Unified · Split
| @@ -757,6 +757,7 @@ static int virtio_ccw_finalize_features(struct virtio_device *vdev) · 756 unmodified lines | ||
| 757 | 757 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
| 758 | 758 | struct virtio_feature_desc *features; |
| 759 | 759 | struct ccw1 *ccw; |
| 760 | + int ret; | |
| 760 | 761 | |
| 761 | 762 | if (vcdev->revision >= 1 && |
| 762 | 763 | !__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) { |
| @@ -767,12 +768,13 @@ static int virtio_ccw_finalize_features(struct virtio_device *vdev) · 4 unmodified lines | ||
| 767 | 768 | |
| 768 | 769 | ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
| 769 | 770 | if (!ccw) |
| 770 | − return 0; | |
| 771 | + return -ENOMEM; | |
| 771 | 772 | |
| 772 | 773 | features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL); |
| 773 | − if (!features) | |
| 774 | + if (!features) { | |
| 775 | + ret = -ENOMEM; | |
| 774 | 776 | goto out_free; |
| 775 | − | |
| 777 | + } | |
| 776 | 778 | /* Give virtio_ring a chance to accept features. */ |
| 777 | 779 | vring_transport_features(vdev); |
| 778 | 780 | |
| @@ -783,7 +785,9 @@ static int virtio_ccw_finalize_features(struct virtio_device *vdev) · 4 unmodified lines | ||
| 783 | 785 | ccw->flags = 0; |
| 784 | 786 | ccw->count = sizeof(*features); |
| 785 | 787 | ccw->cda = (__u32)(unsigned long)features; |
| 786 | − ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); | |
| 788 | + ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); | |
| 789 | + if (ret) | |
| 790 | + goto out_free; | |
| 787 | 791 | |
| 788 | 792 | if (vcdev->revision == 0) |
| 789 | 793 | goto out_free; |
| @@ -795,13 +799,13 @@ static int virtio_ccw_finalize_features(struct virtio_device *vdev) · 5 unmodified lines | ||
| 795 | 799 | ccw->flags = 0; |
| 796 | 800 | ccw->count = sizeof(*features); |
| 797 | 801 | ccw->cda = (__u32)(unsigned long)features; |
| 798 | − ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); | |
| 802 | + ret = ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); | |
| 799 | 803 | |
| 800 | 804 | out_free: |
| 801 | 805 | kfree(features); |
| 802 | 806 | kfree(ccw); |
| 803 | 807 | |
| 804 | − return 0; | |
| 808 | + return ret; | |
| 805 | 809 | } |
| 806 | 810 | |
| 807 | 811 | static void virtio_ccw_get_config(struct virtio_device *vdev, |