diff options
author | Wenwei Tao <ww.tao0320@gmail.com> | 2015-12-09 00:15:52 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-12-21 13:37:53 -0800 |
commit | a2df4e33d71ff819c9afcdf34392030cee349f47 (patch) | |
tree | b5f23fab3c98ec4c4247f8d718e360e4a08f0941 /drivers/staging/android/ashmem.c | |
parent | 59dfafd03fc67d38307d2ba30bbfdd1224b8a75d (diff) | |
download | op-kernel-dev-a2df4e33d71ff819c9afcdf34392030cee349f47.zip op-kernel-dev-a2df4e33d71ff819c9afcdf34392030cee349f47.tar.gz |
staging: android: ashmem.c: destroy slabs when init fails
when ashmem init fails, destroy the slabs, leave
no garbage.
Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/ashmem.c')
-rw-r--r-- | drivers/staging/android/ashmem.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 3f2a3d6..5bb1283 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -831,14 +831,14 @@ static struct miscdevice ashmem_misc = { static int __init ashmem_init(void) { - int ret; + int ret = -ENOMEM; ashmem_area_cachep = kmem_cache_create("ashmem_area_cache", sizeof(struct ashmem_area), 0, 0, NULL); if (unlikely(!ashmem_area_cachep)) { pr_err("failed to create slab cache\n"); - return -ENOMEM; + goto out; } ashmem_range_cachep = kmem_cache_create("ashmem_range_cache", @@ -846,13 +846,13 @@ static int __init ashmem_init(void) 0, 0, NULL); if (unlikely(!ashmem_range_cachep)) { pr_err("failed to create slab cache\n"); - return -ENOMEM; + goto out_free1; } ret = misc_register(&ashmem_misc); if (unlikely(ret)) { pr_err("failed to register misc device!\n"); - return ret; + goto out_free2; } register_shrinker(&ashmem_shrinker); @@ -860,5 +860,12 @@ static int __init ashmem_init(void) pr_info("initialized\n"); return 0; + +out_free2: + kmem_cache_destroy(ashmem_range_cachep); +out_free1: + kmem_cache_destroy(ashmem_area_cachep); +out: + return ret; } device_initcall(ashmem_init); |