aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2018-10-03 13:17:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-15 14:36:46 -0400
commit60a6e5233fcbe82a89b5b83b95b5d87e04b3be60 (patch)
treefcdc96c1733bd309b0ead365129a92bcdb5a1f47
parent08360e26f2a8eba0105ca7cd598547a1749b1c68 (diff)
platform: goldfish: pipe: Call misc_deregister if init fails
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>
-rw-r--r--drivers/platform/goldfish/goldfish_pipe.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 4013832f38fb..c386aaf40034 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -844,8 +844,10 @@ static int goldfish_pipe_device_init(struct platform_device *pdev,
844 dev->pipes_capacity = INITIAL_PIPES_CAPACITY; 844 dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
845 dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes), 845 dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
846 GFP_KERNEL); 846 GFP_KERNEL);
847 if (!dev->pipes) 847 if (!dev->pipes) {
848 misc_deregister(&dev->miscdev);
848 return -ENOMEM; 849 return -ENOMEM;
850 }
849 851
850 /* 852 /*
851 * We're going to pass two buffers, open_command_params and 853 * 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,
858 __get_free_page(GFP_KERNEL); 860 __get_free_page(GFP_KERNEL);
859 if (!dev->buffers) { 861 if (!dev->buffers) {
860 kfree(dev->pipes); 862 kfree(dev->pipes);
863 misc_deregister(&dev->miscdev);
861 return -ENOMEM; 864 return -ENOMEM;
862 } 865 }
863 866