From b080d5a87588520fd3488dbd59250cd82cc88fc9 Mon Sep 17 00:00:00 2001 From: Lance Hartmann Date: Wed, 14 Mar 2018 14:09:50 -0400 Subject: [PATCH] iscsi: Handle spdk_get_pdu() failure in spdk_iscsi_send_r2t() Prepares spdk_iscsi_send_r2t() to handle the case where spdk_get_pdu() will return NULL in a future patch instead of abort()'ing. Change-Id: Id18c39a7ea0ea748f1ecb842aee9a08594fb2a48 Signed-off-by: Lance Hartmann Reviewed-on: https://review.gerrithub.io/403878 Reviewed-by: Shuhei Matsumoto Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/iscsi/iscsi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 000dd7203..934e44602 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -3989,6 +3989,7 @@ spdk_iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn, struct iscsi_bhs_r2t *rsph; uint32_t transfer_len; uint32_t len; + int rc; /* remove the r2t pdu from the snack_list */ pdu = spdk_iscsi_remove_r2t_pdu_from_snack_list(conn, task, r2t_sn); @@ -4020,8 +4021,11 @@ spdk_iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn, spdk_put_pdu(pdu); /* re-send a new r2t pdu */ - spdk_iscsi_send_r2t(conn, task, task->next_expected_r2t_offset, - len, task->ttt, &task->R2TSN); + rc = spdk_iscsi_send_r2t(conn, task, task->next_expected_r2t_offset, + len, task->ttt, &task->R2TSN); + if (rc < 0) { + return SPDK_ISCSI_CONNECTION_FATAL; + } } return 0; @@ -4271,6 +4275,9 @@ spdk_iscsi_send_r2t(struct spdk_iscsi_conn *conn, /* R2T PDU */ rsp_pdu = spdk_get_pdu(); + if (rsp_pdu == NULL) { + return SPDK_ISCSI_CONNECTION_FATAL; + } rsph = (struct iscsi_bhs_r2t *)&rsp_pdu->bhs; rsp_pdu->data = NULL; rsph->opcode = ISCSI_OP_R2T;