staging: ion: Prevent incorrect reference counting behavour
Supply additional check in order to prevent unexpected results.
Fixes: b892bf75b2
("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>
This commit is contained in:
parent
cb158b152e
commit
27da8d16e4
@ -114,6 +114,9 @@ static void *ion_buffer_kmap_get(struct ion_buffer *buffer)
|
|||||||
void *vaddr;
|
void *vaddr;
|
||||||
|
|
||||||
if (buffer->kmap_cnt) {
|
if (buffer->kmap_cnt) {
|
||||||
|
if (buffer->kmap_cnt == INT_MAX)
|
||||||
|
return ERR_PTR(-EOVERFLOW);
|
||||||
|
|
||||||
buffer->kmap_cnt++;
|
buffer->kmap_cnt++;
|
||||||
return buffer->vaddr;
|
return buffer->vaddr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user