Linux-NVME Archive on lore.kernel.org
 help / color / 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	[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, back to index

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

Linux-NVME Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvme/0 linux-nvme/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvme linux-nvme/ https://lore.kernel.org/linux-nvme \
		linux-nvme@lists.infradead.org
	public-inbox-index linux-nvme

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-nvme


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git