Skip to contentSkip to conversation

nvmet-fc: check successful reference in nvmet_fc_find_target_assoc

PATCH Applied James Smart 3 participants 3 messages Jul 24, 2020 – Jul 26, 2020

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

PATCH 1/1 nvmet-fc: check successful reference in nvmet_fc_find_target_assoc

When searching for an association based on an association id, when there is a match, the code takes a reference. However, it is not validating that the reference taking was successful.

Check the status of the reference. If unsuccessful, the device is being deleted and should be ignored.

---
 drivers/nvme/target/fc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/fc.c +2 -1
index 27fd3b5aa621..c15356b5e09f 100644
@@ -1243,7 +1243,8 @@ nvmet_fc_find_target_assoc(struct nvmet_fc_tgtport *tgtport,
 	list_for_each_entry(assoc, &tgtport->assoc_list, a_list) {
 		if (association_id == assoc->association_id) {
 			ret = assoc;
-			nvmet_fc_tgt_a_get(assoc);
+			if (!nvmet_fc_tgt_a_get(assoc))
+				ret = NULL;
 			break;
 		}
 	}
Signature · 7 lines
2.26.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw
In reply to James Smart
Quoted 8 lines · James Smart

When searching for an association based on an association id, when there is a match, the code takes a reference. However, it is not validating that the reference taking was successful.

Check the status of the reference. If unsuccessful, the device is being deleted and should be ignored.

Applied to nvme-5.9, thanks.

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