From 577bbfcfca85b8ad8f6aba274afb61681211b39e Mon Sep 17 00:00:00 2001 From: Sandeep Patil Date: Mon, 9 Sep 2019 08:21:20 -0700 Subject: [PATCH] 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 --- drivers/staging/android/ion/ion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 4631953b9c96..33f6f8f99039 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -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); }