[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <39222c3a041708c41ab3bc1be855ac83912ee07b.1597865771.git.tomersamara98@gmail.com>
Date: Wed, 19 Aug 2020 22:39:34 +0300
From: Tomer Samara <tomersamara98@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Arve Hjønnevåg <arve@...roid.com>,
Riley Andrews <riandrews@...roid.com>,
Laura Abbott <labbott@...hat.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Todd Kjos <tkjos@...roid.com>,
Martijn Coenen <maco@...roid.com>,
Joel Fernandes <joel@...lfernandes.org>,
Christian Brauner <christian@...uner.io>,
Hridya Valsaraju <hridya@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
devel@...verdev.osuosl.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 2/2] staging: android: Remove BUG from ion_system_heap.c
Remove BUG() at ion_sytem_heap.c and error handling to:
- free_buffer_page
- alloc_buffer_page
this fix the following checkpatch issue:
Avoid crashing the kernel - try using WARN_ON &
recovery code ratherthan BUG() or BUG_ON().
Signed-off-by: Tomer Samara <tomersamara98@...il.com>
---
drivers/staging/android/ion/ion_system_heap.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index eac0632ab4e8..56d53268b82c 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -30,7 +30,7 @@ static int order_to_index(unsigned int order)
for (i = 0; i < NUM_ORDERS; i++)
if (order == orders[i])
return i;
- BUG();
+
return -1;
}
@@ -48,8 +48,13 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
struct ion_buffer *buffer,
unsigned long order)
{
- struct ion_page_pool *pool = heap->pools[order_to_index(order)];
+ struct ion_page_pool *pool;
+ int index = order_to_index(order);
+ if (index < 0)
+ return NULL;
+
+ pool = heap->pools[index];
return ion_page_pool_alloc(pool);
}
@@ -58,6 +63,7 @@ static void free_buffer_page(struct ion_system_heap *heap,
{
struct ion_page_pool *pool;
unsigned int order = compound_order(page);
+ int index;
/* go to system */
if (buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE) {
@@ -65,8 +71,11 @@ static void free_buffer_page(struct ion_system_heap *heap,
return;
}
- pool = heap->pools[order_to_index(order)];
+ index = order_to_index(order);
+ if (index < 0)
+ return;
+ pool = heap->pools[index];
ion_page_pool_free(pool, page);
}
--
2.25.1
Powered by blists - more mailing lists