From: James Smart Date: Tue, 22 Sep 2020 21:54:12 +0000 (-0700) Subject: nvmet-fc: fix missing check for no hostport struct X-Git-Tag: v5.15~2713^2~25^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddd3d1051797b9f907ab9799f5ba50398c530676;p=platform%2Fkernel%2Flinux-starfive.git nvmet-fc: fix missing check for no hostport struct A hostport port pointer is allowed to be NULL as it is not allocated if the lldd does not support the new interfaces for NVME LS request support. The hostport free routine validates the handle but forgot to validate the hostport pointer. Validate the hostport pointer before using it to validate the handle. Signed-off-by: James Smart Reviewed-by: Himanshu Madhani Signed-off-by: Christoph Hellwig --- diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index e6861cc..cd4e73a 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1019,7 +1019,7 @@ static void nvmet_fc_free_hostport(struct nvmet_fc_hostport *hostport) { /* if LLDD not implemented, leave as NULL */ - if (!hostport->hosthandle) + if (!hostport || !hostport->hosthandle) return; nvmet_fc_hostport_put(hostport);