summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-10-23 16:29:39 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2018-10-23 16:29:38 -0700
commit8d602672c3cf18bf6ee906439bf1c367afeb0d32 (patch)
treeb37cbedd41acb9bbf7b4ef9044f327a747b8a986
parentd8bc349f5414150a5d59ea73b2d0a2b1fa270043 (diff)
parentbc856c7cae7e9b4b4d03238d4ad9f778889656b5 (diff)
Merge "soc: qcom: hab: add rx queue empty check after getting the lock"
-rw-r--r--drivers/soc/qcom/hab/hab_msg.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/soc/qcom/hab/hab_msg.c b/drivers/soc/qcom/hab/hab_msg.c
index 61e658954312..71010be414d5 100644
--- a/drivers/soc/qcom/hab/hab_msg.c
+++ b/drivers/soc/qcom/hab/hab_msg.c
@@ -64,9 +64,14 @@ hab_msg_dequeue(struct virtual_channel *vchan, struct hab_message **msg,
}
}
- /* return all the received messages before the remote close */
- if ((!ret || (ret == -ERESTARTSYS)) && !hab_rx_queue_empty(vchan)) {
- spin_lock_bh(&vchan->rx_lock);
+ /*
+ * return all the received messages before the remote close,
+ * and need empty check again in case the list is empty now due to
+ * dequeue by other threads
+ */
+ spin_lock_bh(&vchan->rx_lock);
+
+ if ((!ret || (ret == -ERESTARTSYS)) && !list_empty(&vchan->rx_list)) {
message = list_first_entry(&vchan->rx_list,
struct hab_message, node);
if (message) {
@@ -84,11 +89,12 @@ hab_msg_dequeue(struct virtual_channel *vchan, struct hab_message **msg,
ret = -EOVERFLOW; /* come back again */
}
}
- spin_unlock_bh(&vchan->rx_lock);
} else
/* no message received, retain the original status */
*rsize = 0;
+ spin_unlock_bh(&vchan->rx_lock);
+
*msg = message;
return ret;
}