Merge tag 'platform-drivers-x86-v4.20-1' of git://git.infradead.org/linux-platform...
[sfrench/cifs-2.6.git] / drivers / platform / goldfish / goldfish_pipe.c
index 4013832f38fb4eb51af0f81b26eae666897b0147..7c639006252ec912058b8f7c1933b2c2db5dc454 100644 (file)
@@ -715,6 +715,7 @@ static int goldfish_pipe_open(struct inode *inode, struct file *file)
 
        /* Allocate new pipe kernel object */
        struct goldfish_pipe *pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
+
        if (!pipe)
                return -ENOMEM;
 
@@ -844,8 +845,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 +861,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;
        }
 
@@ -922,7 +926,7 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
         *  reading device version back: this allows the host implementation to
         *  detect the old driver (if there was no version write before read).
         */
-       writel((u32)PIPE_DRIVER_VERSION, dev->base + PIPE_REG_VERSION);
+       writel(PIPE_DRIVER_VERSION, dev->base + PIPE_REG_VERSION);
        dev->version = readl(dev->base + PIPE_REG_VERSION);
        if (WARN_ON(dev->version < PIPE_CURRENT_DEVICE_VERSION))
                return -EINVAL;