[SRU][Bionic][PATCH 1/1] staging: ion: Prevent incorrect reference counting behavour

Cengiz Can cengiz.can at canonical.com
Mon Jun 20 15:51:20 UTC 2022

From: Lee Jones <lee.jones at linaro.org>

Supply additional check in order to prevent unexpected results.

Fixes: b892bf75b2034 ("ion: Switch ion to use dma-buf")
Suggested-by: Dan Carpenter <dan.carpenter at oracle.com>
Signed-off-by: Lee Jones <lee.jones at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(cherry picked from commit 618a931c275defc1f258b93754808d59cb4c10a3 linux-4.14.y)
Signed-off-by: Cengiz Can <cengiz.can at canonical.com>
 drivers/staging/android/ion/ion.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 4ec05333da1de..0b50e47502911 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -158,6 +158,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);
 		return buffer->vaddr;

More information about the kernel-team mailing list