ion: fix overflow and list bugs in system heap
authorColin Cross <ccross@android.com>
Fri, 20 Dec 2013 02:37:49 +0000 (18:37 -0800)
committerMitchel Humpherys <mitchelh@codeaurora.org>
Fri, 20 Dec 2013 05:03:30 +0000 (21:03 -0800)
commitc69de844c80884167bb42243b36498dde81eebf6
tree0b86c2a873628d25bf6ff6c371a127124de4e0c6
parent14f162cb64a8beca59f06cd94d5569bd550dc99d
ion: fix overflow and list bugs in system heap

Fix a few bugs in ion_system_heap:

Initialize the list node in the info block.

Don't store size_remaining in a signed long, allocating >2GB
could overflow, resulting in a call to sg_alloc_table with
nents=0 which panics.  alloc_largest_available will never
return a block larger than size_remanining, so it can never
go negative.

Limit a single allocation to half of all memory.  Prevents a
large allocation from taking down the whole system.

Change-Id: I7fcbd7e1d5b4d482d7612d80b6c9e8e24466f1d8
Signed-off-by: Colin Cross <ccross@android.com>
drivers/staging/android/ion/ion_system_heap.c