Commit 50e3b7bf authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Konrad Sztyber
Browse files

nvme_transport: return NULL if transport does not exist



spdk_nvme_ctrlr_get_registers() calls nvme_get_transport()
to get a reference for a transport, whose registers should
be returned, but nvme_get_transport() explicitly returns
NULL, if the transport does not exist. This would result
in dereferencing a NULL pointer on line 862.

To remedy that, if no transport was found, return NULL.

Additionally change "THis" to "This" on line 46.

Change-Id: I3944925659991e9424e2177b5c940b2e2626d1f4
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17532


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 4fafd3fe
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ nvme_get_next_transport(const struct spdk_nvme_transport *transport)

/*
 * Unfortunately, due to NVMe PCIe multiprocess support, we cannot store the
 * transport object in either the controller struct or the admin qpair. THis means
 * transport object in either the controller struct or the admin qpair. This means
 * that a lot of admin related transport calls will have to call nvme_get_transport
 * in order to know which functions to call.
 * In the I/O path, we have the ability to store the transport struct in the I/O
@@ -859,6 +859,11 @@ spdk_nvme_ctrlr_get_registers(struct spdk_nvme_ctrlr *ctrlr)
{
	const struct spdk_nvme_transport *transport = nvme_get_transport(ctrlr->trid.trstring);

	if (transport == NULL) {
		/* Transport does not exist. */
		return NULL;
	}

	if (transport->ops.ctrlr_get_registers) {
		return transport->ops.ctrlr_get_registers(ctrlr);
	}