From: Lee Jones Date: Mon, 25 Apr 2022 15:51:54 +0000 (+0100) Subject: staging: ion: Prevent incorrect reference counting behavour X-Git-Tag: v5.10.113~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fea24b07edfc348c67a019b6e17b39c0698e631f;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 e1fe03ceb7f13..e6d4a3ee6cda5 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -114,6 +114,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; }