From: Lee Jones Date: Mon, 25 Apr 2022 15:51:54 +0000 (+0100) Subject: staging: ion: Prevent incorrect reference counting behavour X-Git-Tag: v4.14.277~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=618a931c275defc1f258b93754808d59cb4c10a3;p=thirdparty%2Fkernel%2Fstable.git staging: ion: Prevent incorrect reference counting behavour Supply additional check in order to prevent unexpected results. Fixes: b892bf75b2034 ("ion: Switch ion to use dma-buf") Suggested-by: Dan Carpenter Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index dd96ca61a5152..986aabc9b8f96 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -160,6 +160,9 @@ static void *ion_buffer_kmap_get(struct ion_buffer *buffer) void *vaddr; if (buffer->kmap_cnt) { + if (buffer->kmap_cnt == INT_MAX) + return ERR_PTR(-EOVERFLOW); + buffer->kmap_cnt++; return buffer->vaddr; }