]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
um: Fix for a possible OOPS in ubd initialization
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>
Tue, 26 Feb 2019 15:55:25 +0000 (15:55 +0000)
committerRichard Weinberger <richard@nod.at>
Wed, 6 Mar 2019 21:39:18 +0000 (22:39 +0100)
If the ubd device failed to allocate a queue during
initialization it tried call blk_cleanup_queue resulting
in an oops.

This patch simplifies the cleanup logic and ensures that
blk_queue_cleanup is called only if there is a valid queue.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/drivers/ubd_kern.c

index a4a41421c5e2a005cca783cfd652e41076b65a93..aca09be2373e77245ec9adfccdb540342a4d0bb9 100644 (file)
@@ -938,7 +938,7 @@ static int ubd_add(int n, char **error_out)
        ubd_dev->queue = blk_mq_init_queue(&ubd_dev->tag_set);
        if (IS_ERR(ubd_dev->queue)) {
                err = PTR_ERR(ubd_dev->queue);
-               goto out_cleanup;
+               goto out_cleanup_tags;
        }
 
        ubd_dev->queue->queuedata = ubd_dev;
@@ -968,8 +968,8 @@ out:
 
 out_cleanup_tags:
        blk_mq_free_tag_set(&ubd_dev->tag_set);
-out_cleanup:
-       blk_cleanup_queue(ubd_dev->queue);
+       if (!(IS_ERR(ubd_dev->queue)))
+               blk_cleanup_queue(ubd_dev->queue);
        goto out;
 }