Skip to contentSkip to conversation

nvmet_fc: on port remove call put outside lock

PATCH New James Smart 2 participants 2 messages Sep 19, 2017 – Sep 20, 2017

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

PATCH 1/1 nvmet_fc: on port remove call put outside lock

Avoid calling the put routine, as it may traverse to free routines while holding the target lock.

Signed-off-by James Smart <james.smart at broadcom.com>
---
 drivers/nvme/target/fc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/nvme/target/fc.c +5 -1
index c48c83d97e30..6850672ad2a2 100644
@@ -2530,13 +2530,17 @@ nvmet_fc_remove_port(struct nvmet_port *port)
 {
 	struct nvmet_fc_tgtport *tgtport = port->priv;
 	unsigned long flags;
+	bool matched = false;
 
 	spin_lock_irqsave(&nvmet_fc_tgtlock, flags);
 	if (tgtport->port == port) {
-		nvmet_fc_tgtport_put(tgtport);
+		matched = true;
 		tgtport->port = NULL;
 	}
 	spin_unlock_irqrestore(&nvmet_fc_tgtlock, flags);
+
+	if (matched)
+		nvmet_fc_tgtport_put(tgtport);
 }
 
 static struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
Signature · 1 line
2.13.1
#1 lore raw

PATCH 1/1 nvmet_fc: on port remove call put outside lock

Looks fine,

Reviewed-by Christoph Hellwig <hch at lst.de>