Skip to content

Commit 34efa23

Browse files
jsmart-ghChristoph Hellwig
authored andcommitted
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. Signed-off-by: James Smart <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 2374807 commit 34efa23

File tree

1 file changed

+2
-1
lines changed
  • drivers/nvme/target

1 file changed

+2
-1
lines changed

drivers/nvme/target/fc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ nvmet_fc_find_target_assoc(struct nvmet_fc_tgtport *tgtport,
12431243
list_for_each_entry(assoc, &tgtport->assoc_list, a_list) {
12441244
if (association_id == assoc->association_id) {
12451245
ret = assoc;
1246-
nvmet_fc_tgt_a_get(assoc);
1246+
if (!nvmet_fc_tgt_a_get(assoc))
1247+
ret = NULL;
12471248
break;
12481249
}
12491250
}

0 commit comments

Comments
 (0)