From cffdfea367bc56ca47ebeb24eeed5ef505632677 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 13 Jan 2021 16:52:58 +0900 Subject: [PATCH] Staging: android: ion: fix to set cached element of pool always The allocated memory with kmalloc() can have invalid value. To avoid using the invalid value, always set cached element. This removes below UBSAN warning: UBSAN: Undefined behaviour in drivers/staging/android/ion/ion_page_pool.c:33:11 load of value 152 is not a valid value for type '_Bool' ... [] __ubsan_handle_load_invalid_value+0x80/0x90 [] ion_page_pool_alloc+0x154/0x180 [] ion_system_heap_allocate+0x2b8/0xa68 [] ion_alloc+0x238/0x9c8 ... Change-Id: I86e0ee70404bb074dad3b73dccec31ebcf2c7c72 Signed-off-by: Seung-Woo Kim --- drivers/staging/android/ion/ion_page_pool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index aea89c1ec..c34d921 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -163,8 +163,7 @@ struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order, pool->order = order; mutex_init(&pool->mutex); plist_node_init(&pool->list, order); - if (cached) - pool->cached = true; + pool->cached = cached; return pool; } -- 2.7.4