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: Krzysztof Karas <krzysztof.karas@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17532 Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
7f292dd457
commit
b890bd21cd
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user