mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 01:41:39 +00:00
virtio-rng: refactor probe error handling
Code like vi->vq = NULL; kfree(vi) does not make sense. Clean it up, use goto error labels for cleanup. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5d8f16d08b
commit
1bbc260627
1 changed files with 9 additions and 6 deletions
|
@ -105,8 +105,8 @@ static int probe_common(struct virtio_device *vdev)
|
|||
|
||||
vi->index = index = ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL);
|
||||
if (index < 0) {
|
||||
kfree(vi);
|
||||
return index;
|
||||
err = index;
|
||||
goto err_ida;
|
||||
}
|
||||
sprintf(vi->name, "virtio_rng.%d", index);
|
||||
init_completion(&vi->have_data);
|
||||
|
@ -124,13 +124,16 @@ static int probe_common(struct virtio_device *vdev)
|
|||
vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input");
|
||||
if (IS_ERR(vi->vq)) {
|
||||
err = PTR_ERR(vi->vq);
|
||||
vi->vq = NULL;
|
||||
kfree(vi);
|
||||
ida_simple_remove(&rng_index_ida, index);
|
||||
return err;
|
||||
goto err_find;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_find:
|
||||
ida_simple_remove(&rng_index_ida, index);
|
||||
err_ida:
|
||||
kfree(vi);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void remove_common(struct virtio_device *vdev)
|
||||
|
|
Loading…
Reference in a new issue