]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
platform: goldfish: pipe: Call misc_deregister if init fails
authorRoman Kiryanov <rkir@google.com>
Wed, 3 Oct 2018 17:17:09 +0000 (10:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Oct 2018 18:36:46 +0000 (20:36 +0200)
Undo effects of misc_register if driver's init fails after
misc_register.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/platform/goldfish/goldfish_pipe.c

index 4013832f38fb4eb51af0f81b26eae666897b0147..c386aaf40034f09ef587774b31e866365fade8d0 100644 (file)
@@ -844,8 +844,10 @@ static int goldfish_pipe_device_init(struct platform_device *pdev,
        dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
        dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
                             GFP_KERNEL);
-       if (!dev->pipes)
+       if (!dev->pipes) {
+               misc_deregister(&dev->miscdev);
                return -ENOMEM;
+       }
 
        /*
         * We're going to pass two buffers, open_command_params and
@@ -858,6 +860,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev,
                __get_free_page(GFP_KERNEL);
        if (!dev->buffers) {
                kfree(dev->pipes);
+               misc_deregister(&dev->miscdev);
                return -ENOMEM;
        }