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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
08360e26f2
commit
60a6e5233f
@@ -844,8 +844,10 @@ static int goldfish_pipe_device_init(struct platform_device *pdev,
|
|||||||
dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
|
dev->pipes_capacity = INITIAL_PIPES_CAPACITY;
|
||||||
dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
|
dev->pipes = kcalloc(dev->pipes_capacity, sizeof(*dev->pipes),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!dev->pipes)
|
if (!dev->pipes) {
|
||||||
|
misc_deregister(&dev->miscdev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're going to pass two buffers, open_command_params and
|
* 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);
|
__get_free_page(GFP_KERNEL);
|
||||||
if (!dev->buffers) {
|
if (!dev->buffers) {
|
||||||
kfree(dev->pipes);
|
kfree(dev->pipes);
|
||||||
|
misc_deregister(&dev->miscdev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user