providers/irdma: Check QP handle before decoding CQE errors
When a QP is destroyed, any pending completions for it are scrubbed
from the associated CQ ring(s) by setting the QP handle value to NULL.
When completions are polled, these scrubbed CQEs are identified and
skipped by checking for a NULL QP handle, but this check was
located after the QP handle could already be dereferenced.
Fix this by moving the NULL check earlier, right after the handle
is obtained.
Fixes: d986d0b2cc01 ("providers/irdma: Flush changes for GEN 3")
Signed-off-by: Jacob Moroni <jmoroni@google.com>
diff --git a/providers/irdma/uk.c b/providers/irdma/uk.c
index dc863a4..4556676 100644
--- a/providers/irdma/uk.c
+++ b/providers/irdma/uk.c
@@ -1366,6 +1366,10 @@
get_64bit_val(cqe, 40, (__u64 *)&qp);
else
qp = (struct irdma_qp_uk *)(uintptr_t)comp_ctx;
+ if (!qp || qp->destroy_pending) {
+ ret_code = EFAULT;
+ goto exit;
+ }
if (info->error) {
info->major_err = FIELD_GET(IRDMA_CQ_MAJERR, qword3);
info->minor_err = FIELD_GET(IRDMA_CQ_MINERR, qword3);
@@ -1412,10 +1416,6 @@
info->ud_src_qpn = (__u32)FIELD_GET(IRDMACQ_UDSRCQPN, qword2);
info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3);
- if (!qp || qp->destroy_pending) {
- ret_code = EFAULT;
- goto exit;
- }
wqe_idx = (__u32)FIELD_GET(IRDMA_CQ_WQEIDX, qword3);
info->qp_handle = (irdma_qp_handle)(uintptr_t)qp;
info->op_type = (__u8)FIELD_GET(IRDMACQ_OP, qword3);