diff mbox series

[10/15] RDMA/srpt: Fix handling of iWARP logins

Message ID 20190930231707.48259-11-bvanassche@acm.org (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA patches for kernel v5.5 | expand

Commit Message

Bart Van Assche Sept. 30, 2019, 11:17 p.m. UTC
The path_rec pointer is NULL set for IB and RoCE logins but not for iWARP
logins. Hence check the path_rec pointer before dereferencing it.

Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe Oct. 2, 2019, 2:16 p.m. UTC | #1
On Mon, Sep 30, 2019 at 04:17:02PM -0700, Bart Van Assche wrote:
> The path_rec pointer is NULL set for IB and RoCE logins but not for iWARP
> logins. Hence check the path_rec pointer before dereferencing it.

Did you mean it is null set for iWARP logins? I would expect iwarp to
not have a pkey..

Jason
Bart Van Assche Oct. 2, 2019, 3:23 p.m. UTC | #2
On 10/2/19 7:16 AM, Jason Gunthorpe wrote:
> On Mon, Sep 30, 2019 at 04:17:02PM -0700, Bart Van Assche wrote:
>> The path_rec pointer is NULL set for IB and RoCE logins but not for iWARP
>> logins. Hence check the path_rec pointer before dereferencing it.
> 
> Did you mean it is null set for iWARP logins? I would expect iwarp to
> not have a pkey..

Yes, I meant that the path_rec pointer is NULL for iWARP logins. The
word "NULL" should be removed from the commit message.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 4f99a5e040c3..fbfadeedc195 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2502,6 +2502,7 @@  static int srpt_rdma_cm_req_recv(struct rdma_cm_id *cm_id,
 	struct srpt_device *sdev;
 	struct srp_login_req req;
 	const struct srp_login_req_rdma *req_rdma;
+	struct sa_path_rec *path_rec = cm_id->route.path_rec;
 	char src_addr[40];
 
 	sdev = ib_get_client_data(cm_id->device, &srpt_client);
@@ -2527,7 +2528,7 @@  static int srpt_rdma_cm_req_recv(struct rdma_cm_id *cm_id,
 		 &cm_id->route.addr.src_addr);
 
 	return srpt_cm_req_recv(sdev, NULL, cm_id, cm_id->port_num,
-				cm_id->route.path_rec->pkey, &req, src_addr);
+				path_rec ? path_rec->pkey : 0, &req, src_addr);
 }
 
 static void srpt_cm_rej_recv(struct srpt_rdma_ch *ch,