|
@@ -831,14 +831,14 @@ static struct miscdevice ashmem_misc = {
|
|
|
|
|
|
|
|
static int __init ashmem_init(void)
|
|
static int __init ashmem_init(void)
|
|
|
{
|
|
{
|
|
|
- int ret;
|
|
|
|
|
|
|
+ int ret = -ENOMEM;
|
|
|
|
|
|
|
|
ashmem_area_cachep = kmem_cache_create("ashmem_area_cache",
|
|
ashmem_area_cachep = kmem_cache_create("ashmem_area_cache",
|
|
|
sizeof(struct ashmem_area),
|
|
sizeof(struct ashmem_area),
|
|
|
0, 0, NULL);
|
|
0, 0, NULL);
|
|
|
if (unlikely(!ashmem_area_cachep)) {
|
|
if (unlikely(!ashmem_area_cachep)) {
|
|
|
pr_err("failed to create slab cache\n");
|
|
pr_err("failed to create slab cache\n");
|
|
|
- return -ENOMEM;
|
|
|
|
|
|
|
+ goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ashmem_range_cachep = kmem_cache_create("ashmem_range_cache",
|
|
ashmem_range_cachep = kmem_cache_create("ashmem_range_cache",
|
|
@@ -846,13 +846,13 @@ static int __init ashmem_init(void)
|
|
|
0, 0, NULL);
|
|
0, 0, NULL);
|
|
|
if (unlikely(!ashmem_range_cachep)) {
|
|
if (unlikely(!ashmem_range_cachep)) {
|
|
|
pr_err("failed to create slab cache\n");
|
|
pr_err("failed to create slab cache\n");
|
|
|
- return -ENOMEM;
|
|
|
|
|
|
|
+ goto out_free1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ret = misc_register(&ashmem_misc);
|
|
ret = misc_register(&ashmem_misc);
|
|
|
if (unlikely(ret)) {
|
|
if (unlikely(ret)) {
|
|
|
pr_err("failed to register misc device!\n");
|
|
pr_err("failed to register misc device!\n");
|
|
|
- return ret;
|
|
|
|
|
|
|
+ goto out_free2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
register_shrinker(&ashmem_shrinker);
|
|
register_shrinker(&ashmem_shrinker);
|
|
@@ -860,5 +860,12 @@ static int __init ashmem_init(void)
|
|
|
pr_info("initialized\n");
|
|
pr_info("initialized\n");
|
|
|
|
|
|
|
|
return 0;
|
|
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);
|
|
device_initcall(ashmem_init);
|