Commit 1f3bd08f authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

nvme/tcp: check tcp_req for NULL in pdu_payload_handle



For a C2HTermReq PDU, there's no associated tcp_req, so we need to check
it for NULL before dereferencing it.

Also, while here, moved some of the assignments to the declarations to
reduce the number of boilerplate lines.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Iac05ef0ba605e2f40d0026ad1b131c28d29f7314
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12845


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 14adf7f7
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1126,22 +1126,23 @@ nvme_tcp_pdu_payload_handle(struct nvme_tcp_qpair *tqpair,
			    uint32_t *reaped)
{
	int rc = 0;
	struct nvme_tcp_pdu *pdu;
	struct nvme_tcp_pdu *pdu = tqpair->recv_pdu;
	uint32_t crc32c;
	struct nvme_tcp_poll_group *tgroup;
	struct nvme_tcp_req *tcp_req;
	struct nvme_tcp_req *tcp_req = pdu->req;

	assert(tqpair->recv_state == NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD);
	pdu = tqpair->recv_pdu;

	SPDK_DEBUGLOG(nvme, "enter\n");

	tcp_req = pdu->req;
	/* Increase the expected data offset */
	/* The request can be NULL, e.g. in case of C2HTermReq */
	if (spdk_likely(tcp_req != NULL)) {
		tcp_req->expected_datao += pdu->data_len;
	}

	/* check data digest if need */
	if (pdu->ddgst_enable) {
		/* But if the data digest is enabled, tcp_req cannot be NULL */
		assert(tcp_req != NULL);
		tgroup = nvme_tcp_poll_group(tqpair->qpair.poll_group);
		/* Only suport this limitated case for the first step */
		if ((nvme_qpair_get_state(&tqpair->qpair) >= NVME_QPAIR_CONNECTED) &&