staging: ion: fix off-by-1 error in heap search

ion allocation was wrong because of an off-by-1 error
in heap search for buffer allocation. Fix it.

Bug: 140507100
Test: ion-unit-tests

Change-Id: I6ac5b0ddc6b31b5409645f62a96781d464b7bdf3
Signed-off-by: Sandeep Patil <sspatil@google.com>
This commit is contained in:
Sandeep Patil
2019-09-09 08:21:20 -07:00
parent b7ee32b12f
commit 577bbfcfca

View File

@@ -279,7 +279,7 @@ static int ion_assign_heap_id(struct ion_heap *heap, struct ion_device *dev)
if (test_and_set_bit(id_bit - 1, dev->heap_ids))
return -EEXIST;
heap->id = id_bit;
heap->id = id_bit - 1;
dev->heap_cnt++;
return 0;
@@ -392,7 +392,7 @@ void ion_device_remove_heap(struct ion_heap *heap)
__func__, heap->name);
}
debugfs_remove_recursive(heap->debugfs_dir);
clear_bit(heap->id - 1, dev->heap_ids);
clear_bit(heap->id, dev->heap_ids);
dev->heap_cnt--;
up_write(&dev->lock);
}