Skip to content

Commit

Permalink
staging: ion: Prevent incorrect reference counting behavour
Browse files Browse the repository at this point in the history
Supply additional check in order to prevent unexpected results.

Fixes: b892bf7 ("ion: Switch ion to use dma-buf")
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Lee Jones authored and Greg Kroah-Hartman committed Apr 27, 2022
1 parent dccee74 commit fea24b0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/staging/android/ion/ion.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit fea24b0

Please sign in to comment.