From 660ac56e1ee71a177554432e9b9994aea1bdd0d4 Mon Sep 17 00:00:00 2001
From: Sindhu-Devale <sindhu.devale@intel.com>
Date: Thu, 8 Sep 2022 17:22:32 -0400
Subject: providers/irdma: Use s/g array in post send only when its valid

[ Upstream commit 7bc6e3b49cdac9776e740e9d886e3676524996f8 ]

Send with invalidate verb call can pass in an
uninitialized s/g array with 0 sge's which is
filled into irdma WQE and causes a HW asynchronous event.

Fix this by using the s/g array in irdma post send only when its valid.

Fixes: 3bebdf5 ("rdma-core/irdma: Add user/kernel shared libraries")
Signed-off-by: Tatyana Nikolova tatyana.e.nikolova@intel.com
Signed-off-by: Sindhu-Devale <sindhu.devale@intel.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
---
 providers/irdma/uk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/providers/irdma/uk.c b/providers/irdma/uk.c
index beda34b..43ea45a 100644
--- a/providers/irdma/uk.c
+++ b/providers/irdma/uk.c
@@ -476,7 +476,8 @@ enum irdma_status_code irdma_uk_send(struct irdma_qp_uk *qp,
 			      FIELD_PREP(IRDMAQPSQ_IMMDATA, info->imm_data));
 		i = 0;
 	} else {
-		qp->wqe_ops.iw_set_fragment(wqe, 0, op_info->sg_list,
+		qp->wqe_ops.iw_set_fragment(wqe, 0,
+					    frag_cnt ? op_info->sg_list : NULL,
 					    qp->swqe_polarity);
 		i = 1;
 	}
-- 
2.34.1

