aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/android/ion
diff options
context:
space:
mode:
authorNathan Chancellor <natechancellor@gmail.com>2018-05-14 11:50:44 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-15 09:31:38 +0200
commitdabb01c2d093faec26ae478a050c42a507d39953 (patch)
tree90e7a7b487b2b0859ac6c40ef8e6854343a76aad /drivers/staging/android/ion
parentstaging: speakup: use true/false instead of 1/0 (diff)
downloadlinux-dev-dabb01c2d093faec26ae478a050c42a507d39953.tar.xz
linux-dev-dabb01c2d093faec26ae478a050c42a507d39953.zip
staging: android: ion: Check return value of ion_buffer_kmap_get
GCC warns that vaddr is set but unused. Check the return value of ion_buffer_kmap_get to make vaddr useful and make sure everything is properly configured before beginning a DMA. Suggested-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/ion')
-rw-r--r--drivers/staging/android/ion/ion.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index d10b60fe4a29..af682cbde767 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -315,6 +315,7 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
struct ion_buffer *buffer = dmabuf->priv;
void *vaddr;
struct ion_dma_buf_attachment *a;
+ int ret = 0;
/*
* TODO: Move this elsewhere because we don't always need a vaddr
@@ -322,6 +323,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
if (buffer->heap->ops->map_kernel) {
mutex_lock(&buffer->lock);
vaddr = ion_buffer_kmap_get(buffer);
+ if (IS_ERR(vaddr)) {
+ ret = PTR_ERR(vaddr);
+ goto unlock;
+ }
mutex_unlock(&buffer->lock);
}
@@ -330,9 +335,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
direction);
}
- mutex_unlock(&buffer->lock);
- return 0;
+unlock:
+ mutex_unlock(&buffer->lock);
+ return ret;
}
static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,