linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet-fc: check successful reference in nvmet_fc_find_target_assoc
@ 2020-07-24 16:40 James Smart
  2020-07-24 23:16 ` Sagi Grimberg
  2020-07-26 15:43 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: James Smart @ 2020-07-24 16:40 UTC (permalink / raw)
  To: linux-nvme; +Cc: 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.

Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/nvme/target/fc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 27fd3b5aa621..c15356b5e09f 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -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;
 		}
 	}
-- 
2.26.2


_______________________________________________
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: check successful reference in nvmet_fc_find_target_assoc
  2020-07-24 16:40 [PATCH] nvmet-fc: check successful reference in nvmet_fc_find_target_assoc James Smart
@ 2020-07-24 23:16 ` Sagi Grimberg
  2020-07-26 15:43 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2020-07-24 23:16 UTC (permalink / raw)
  To: James Smart, linux-nvme

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
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: check successful reference in nvmet_fc_find_target_assoc
  2020-07-24 16:40 [PATCH] nvmet-fc: check successful reference in nvmet_fc_find_target_assoc James Smart
  2020-07-24 23:16 ` Sagi Grimberg
@ 2020-07-26 15:43 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-07-26 15:43 UTC (permalink / raw)
  To: James Smart; +Cc: linux-nvme

On Fri, Jul 24, 2020 at 09:40:00AM -0700, James Smart wrote:
> 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 <jsmart2021@gmail.com>

Applied to nvme-5.9, thanks.

_______________________________________________
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-07-26 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 16:40 [PATCH] nvmet-fc: check successful reference in nvmet_fc_find_target_assoc James Smart
2020-07-24 23:16 ` Sagi Grimberg
2020-07-26 15:43 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).