From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: [PATCH 02/14] IB/srp: Fix race between srp_queuecommand() and srp_claim_req() Date: Wed, 12 Jun 2013 15:21:50 +0200 Message-ID: <51B875EE.3030702@acm.org> References: <51B87501.4070005@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51B87501.4070005-HInyCGIudOg@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Roland Dreier Cc: David Dillow , Vu Pham , Sebastian Riemer , linux-rdma List-Id: linux-rdma@vger.kernel.org Avoid that srp_claim_command() can claim a command while srp_queuecommand() is still busy queueing the same command. Found this via source reading. Signed-off-by: Bart Van Assche Cc: Roland Dreier Cc: David Dillow Cc: Vu Pham Cc: Sebastian Riemer --- drivers/infiniband/ulp/srp/ib_srp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 368d160..9c638dd 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1367,7 +1367,6 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) req = list_first_entry(&target->free_reqs, struct srp_request, list); list_del(&req->list); - spin_unlock_irqrestore(&target->lock, flags); dev = target->srp_host->srp_dev->dev; ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_iu_len, @@ -1401,6 +1400,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) shost_printk(KERN_ERR, target->scsi_host, PFX "Send failed\n"); goto err_unmap; } + spin_unlock_irqrestore(&target->lock, flags); return 0; @@ -1409,8 +1409,6 @@ err_unmap: err_iu: srp_put_tx_iu(target, iu, SRP_IU_CMD); - - spin_lock_irqsave(&target->lock, flags); list_add(&req->list, &target->free_reqs); err_unlock: -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html