mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 11:21:33 +00:00
staging: android: check for error from register_shrinker in ion_heap_init_shrinker
The function register_shrinker in ion_heap_init_shrinker may return an error, check it out. Meanwhile, ion_heap_init_shrinker has to a return value. Signed-off-by: Xiongwei Song <sxwjean@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a941f70e55
commit
47ac54e877
@ -529,6 +529,7 @@ void ion_device_add_heap(struct ion_heap *heap)
|
||||
{
|
||||
struct dentry *debug_file;
|
||||
struct ion_device *dev = internal_dev;
|
||||
int ret;
|
||||
|
||||
if (!heap->ops->allocate || !heap->ops->free)
|
||||
pr_err("%s: can not add heap with invalid ops struct.\n",
|
||||
@ -540,8 +541,11 @@ void ion_device_add_heap(struct ion_heap *heap)
|
||||
if (heap->flags & ION_HEAP_FLAG_DEFER_FREE)
|
||||
ion_heap_init_deferred_free(heap);
|
||||
|
||||
if ((heap->flags & ION_HEAP_FLAG_DEFER_FREE) || heap->ops->shrink)
|
||||
ion_heap_init_shrinker(heap);
|
||||
if ((heap->flags & ION_HEAP_FLAG_DEFER_FREE) || heap->ops->shrink) {
|
||||
ret = ion_heap_init_shrinker(heap);
|
||||
if (ret)
|
||||
pr_err("%s: Failed to register shrinker\n", __func__);
|
||||
}
|
||||
|
||||
heap->dev = dev;
|
||||
down_write(&dev->lock);
|
||||
|
@ -230,7 +230,7 @@ int ion_alloc(size_t len,
|
||||
* this function will be called to setup a shrinker to shrink the freelists
|
||||
* and call the heap's shrink op.
|
||||
*/
|
||||
void ion_heap_init_shrinker(struct ion_heap *heap);
|
||||
int ion_heap_init_shrinker(struct ion_heap *heap);
|
||||
|
||||
/**
|
||||
* ion_heap_init_deferred_free -- initialize deferred free functionality
|
||||
|
@ -297,11 +297,12 @@ static unsigned long ion_heap_shrink_scan(struct shrinker *shrinker,
|
||||
return freed;
|
||||
}
|
||||
|
||||
void ion_heap_init_shrinker(struct ion_heap *heap)
|
||||
int ion_heap_init_shrinker(struct ion_heap *heap)
|
||||
{
|
||||
heap->shrinker.count_objects = ion_heap_shrink_count;
|
||||
heap->shrinker.scan_objects = ion_heap_shrink_scan;
|
||||
heap->shrinker.seeks = DEFAULT_SEEKS;
|
||||
heap->shrinker.batch = 0;
|
||||
register_shrinker(&heap->shrinker);
|
||||
|
||||
return register_shrinker(&heap->shrinker);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user