summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Samuelov <amirs@codeaurora.org>2016-05-31 10:13:26 +0300
committerKyle Yan <kyan@codeaurora.org>2016-05-31 15:26:18 -0700
commitd8b33a2dac2e94dda2f0a09975ec7db9a7d1fcff (patch)
treec902fc864d4e1bb729d3cc538a81d0608fa962e6
parent62a5a6aa32197c8a2f01062b421bd9d229a48f5a (diff)
spcom: fix lock ION buffer
Check if ION buffer is locked based on comparing the kernel ion handle, rather than comparing the user file descriptor. Change-Id: I7a41df3eebf22de2cc6b14327978923bcdbb7142 Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
-rw-r--r--drivers/soc/qcom/spcom.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c
index a5e17991f122..24c8d911ef17 100644
--- a/drivers/soc/qcom/spcom.c
+++ b/drivers/soc/qcom/spcom.c
@@ -1520,12 +1520,6 @@ static int spcom_handle_lock_ion_buf_command(struct spcom_channel *ch,
return -ENODEV;
}
- /* Check if this FD is already locked */
- for (i = 0 ; i < SPCOM_MAX_ION_BUF ; i++)
- if (ch->ion_fd_table[i] == fd) {
- pr_debug("fd [%d] is already locked.\n", fd);
- return -EINVAL;
- }
/* Get ION handle from fd - this increments the ref count */
ion_handle = ion_import_dma_buf(spcom_dev->ion_client, fd);
@@ -1535,6 +1529,17 @@ static int spcom_handle_lock_ion_buf_command(struct spcom_channel *ch,
}
pr_debug("ion handle ok.\n");
+ /* Check if this ION buffer is already locked */
+ for (i = 0 ; i < SPCOM_MAX_ION_BUF ; i++) {
+ if (ch->ion_handle_table[i] == ion_handle) {
+ pr_debug("fd [%d] ion buf is already locked.\n", fd);
+ /* decrement back the ref count */
+ ion_free(spcom_dev->ion_client, ion_handle);
+ return -EINVAL;
+ }
+ }
+
+ /* Store the ION handle */
for (i = 0 ; i < SPCOM_MAX_ION_BUF ; i++) {
if (ch->ion_handle_table[i] == NULL) {
ch->ion_handle_table[i] = ion_handle;