[PATCH] nvmet-fc: fix missing check for no hostport struct

Himanshu Madhani himanshu.madhani at oracle.com
Wed Sep 23 10:07:47 EDT 2020


On 9/22/20 4:54 PM, James Smart wrote:
> 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 at broadcom.com>
> ---
>   drivers/nvme/target/fc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index e6861cc10e7d..cd4e73aa9807 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);
> 
> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
> 

Looks fine.

Reviewed-by: Himanshu Madhani <himanshu.madhani at oracle.com>

-- 
Himanshu Madhani                         Oracle Linux Engineering



More information about the Linux-nvme mailing list