]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet-fc: fix missing check for no hostport struct
authorJames Smart <james.smart@broadcom.com>
Tue, 22 Sep 2020 21:54:12 +0000 (14:54 -0700)
committerChristoph Hellwig <hch@lst.de>
Sun, 27 Sep 2020 07:14:19 +0000 (09:14 +0200)
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 <james.smart@broadcom.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/fc.c

index e6861cc10e7db36400af6faa36149242a71d7694..cd4e73aa98074e85e00004a36672e5c928af9b92 100644 (file)
@@ -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);