Skip to contentSkip to conversation

nvmet-fc: fix missing check for no hostport struct

PATCH Applied James Smart 3 participants 3 messages Sep 22, 2020 – Sep 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/nvme/target/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index e6861cc10e7d..cd4e73aa9807 100644
@@ -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);
Signature · 1 line
2.26.2

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · James Smart

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.

---
  drivers/nvme/target/fc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index e6861cc10e7d..cd4e73aa9807 100644
@@ -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);
Quoted 5 lines

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Looks fine.

Signature · 6 lines
Himanshu Madhani                         Oracle Linux Engineering

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme