Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-fc: fix missing check for no hostport struct
@ 2020-09-22 21:54 James Smart
  2020-09-23 14:07 ` Himanshu Madhani
  2020-09-24  5:10 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: James Smart @ 2020-09-22 21:54 UTC (permalink / raw)
  To: linux-nvme; +Cc: James Smart


[-- Attachment #1.1: Type: text/plain, Size: 891 bytes --]

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>
---
 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);
-- 
2.26.2


[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4163 bytes --]

[-- Attachment #2: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet-fc: fix missing check for no hostport struct
  2020-09-22 21:54 [PATCH] nvmet-fc: fix missing check for no hostport struct James Smart
@ 2020-09-23 14:07 ` Himanshu Madhani
  2020-09-24  5:10 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Himanshu Madhani @ 2020-09-23 14:07 UTC (permalink / raw)
  To: James Smart, linux-nvme

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@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@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
> 

Looks fine.

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

-- 
Himanshu Madhani                         Oracle Linux Engineering

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet-fc: fix missing check for no hostport struct
  2020-09-22 21:54 [PATCH] nvmet-fc: fix missing check for no hostport struct James Smart
  2020-09-23 14:07 ` Himanshu Madhani
@ 2020-09-24  5:10 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-09-24  5:10 UTC (permalink / raw)
  To: James Smart; +Cc: linux-nvme

Thanks,

applied to nvme-5.10.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-24  5:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-22 21:54 [PATCH] nvmet-fc: fix missing check for no hostport struct James Smart
2020-09-23 14:07 ` Himanshu Madhani
2020-09-24  5:10 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox