Staging: android: ion: fix to set cached element of pool always 75/251375/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 13 Jan 2021 07:52:58 +0000 (16:52 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 13 Jan 2021 08:01:55 +0000 (17:01 +0900)
commitcffdfea367bc56ca47ebeb24eeed5ef505632677
treef27602e795e1bae076e38b21408c921d62b36074
parented433ca707269cd22fa1137c33818af6c254eea4
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'
   ...
   [<ffffff9009b89e48>] __ubsan_handle_load_invalid_value+0x80/0x90
   [<ffffff900a2c4044>] ion_page_pool_alloc+0x154/0x180
   [<ffffff900a2c5b60>] ion_system_heap_allocate+0x2b8/0xa68
   [<ffffff900a2c0688>] ion_alloc+0x238/0x9c8
   ...

Change-Id: I86e0ee70404bb074dad3b73dccec31ebcf2c7c72
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/staging/android/ion/ion_page_pool.c