diff options
Diffstat (limited to 'drivers/char/hw_random/virtio-rng.c')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 132c9ccfdc62..72295ea2fd1c 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
@@ -109,8 +109,8 @@ static int probe_common(struct virtio_device *vdev) | |||
109 | 109 | ||
110 | vi->index = index = ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL); | 110 | vi->index = index = ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL); |
111 | if (index < 0) { | 111 | if (index < 0) { |
112 | kfree(vi); | 112 | err = index; |
113 | return index; | 113 | goto err_ida; |
114 | } | 114 | } |
115 | sprintf(vi->name, "virtio_rng.%d", index); | 115 | sprintf(vi->name, "virtio_rng.%d", index); |
116 | init_completion(&vi->have_data); | 116 | init_completion(&vi->have_data); |
@@ -128,13 +128,16 @@ static int probe_common(struct virtio_device *vdev) | |||
128 | vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input"); | 128 | vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input"); |
129 | if (IS_ERR(vi->vq)) { | 129 | if (IS_ERR(vi->vq)) { |
130 | err = PTR_ERR(vi->vq); | 130 | err = PTR_ERR(vi->vq); |
131 | vi->vq = NULL; | 131 | goto err_find; |
132 | kfree(vi); | ||
133 | ida_simple_remove(&rng_index_ida, index); | ||
134 | return err; | ||
135 | } | 132 | } |
136 | 133 | ||
137 | return 0; | 134 | return 0; |
135 | |||
136 | err_find: | ||
137 | ida_simple_remove(&rng_index_ida, index); | ||
138 | err_ida: | ||
139 | kfree(vi); | ||
140 | return err; | ||
138 | } | 141 | } |
139 | 142 | ||
140 | static void remove_common(struct virtio_device *vdev) | 143 | static void remove_common(struct virtio_device *vdev) |