Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: ion: WARN when the handle kmap_cnt is going to wrap around

There are certain client bugs (double unmap, for example) that can cause
the handle->kmap_cnt (an unsigned int) to wrap around from zero. This
causes problems when the handle is destroyed because we have:

while (handle->kmap_cnt)
ion_handle_kmap_put(handle);

which takes a long time to complete when kmap_cnt starts at ~0 and can
result in a watchdog timeout.

WARN and bail when kmap_cnt is about to wrap around from zero.

Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Acked-by: Colin Cross <ccross@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mitchel Humpherys and committed by
Greg Kroah-Hartman
22f6b978 7949f30a

+4
+4
drivers/staging/android/ion/ion.c
··· 627 627 { 628 628 struct ion_buffer *buffer = handle->buffer; 629 629 630 + if (!handle->kmap_cnt) { 631 + WARN(1, "%s: Double unmap detected! bailing...\n", __func__); 632 + return; 633 + } 630 634 handle->kmap_cnt--; 631 635 if (!handle->kmap_cnt) 632 636 ion_buffer_kmap_put(buffer);