Commit 30af49f7 authored by Weiguo Li's avatar Weiguo Li Committed by Tomasz Zawadzki
Browse files

nvmf: avoid a null dereference before null check



We do the null check for 'fc_req', but already dereferenced it
before the check. Swap their position to avoid null dereference.

Fixes issue #2395.

Signed-off-by: default avatarWeiguo Li <liwg06@foxmail.com>
Change-Id: I33b9e6b51b54f6ada9c072cf7ab0acda2622472f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11721


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
parent 5f270928
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1586,12 +1586,13 @@ nvmf_fc_hwqp_handle_request(struct spdk_nvmf_fc_hwqp *hwqp, struct spdk_nvmf_fc_
void
_nvmf_fc_request_free(struct spdk_nvmf_fc_request *fc_req)
{
	struct spdk_nvmf_fc_hwqp *hwqp = fc_req->hwqp;
	struct spdk_nvmf_fc_hwqp *hwqp;
	struct spdk_nvmf_transport_poll_group *group;

	if (!fc_req) {
		return;
	}
	hwqp = fc_req->hwqp;

	if (fc_req->xchg) {
		nvmf_fc_put_xchg(hwqp, fc_req->xchg);