trusty: ql_tipc: Re-fix random stuck boottests am: d9b56a6a14

Original change: https://android-review.googlesource.com/c/trusty/lk/trusty/+/3508175

Change-Id: I5f6661e36c70979488adae85d47c009889ca02b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/lib/trusty/tipc_dev_ql.c b/lib/trusty/tipc_dev_ql.c
index ecc58b7..31d4299 100644
--- a/lib/trusty/tipc_dev_ql.c
+++ b/lib/trusty/tipc_dev_ql.c
@@ -485,8 +485,15 @@
                           uint32_t target) {
     const int opcode = QL_TIPC_DEV_FC_HAS_EVENT;
 
-    if (ns_sz < (sizeof(struct tipc_cmd_hdr) + sizeof(bool)) ||
-        ns_sz > dev->ns_sz) {
+    /*
+     * Ignore ns_sz. The client sets payload_len to 0 since the payload is
+     * only used to return data, no data is passed in.
+     *
+     * Check that buffer is large enough for the response, even though this
+     * check can't fail with the current struct size, since dev->ns_sz has
+     * already been checked to be page aligned and non-0.
+     */
+    if ((sizeof(struct tipc_cmd_hdr) + sizeof(bool)) > dev->ns_sz) {
         return set_status(dev, opcode, ERR_INVALID_ARGS, 0);
     }