Skip to contentSkip to conversation

xen-scsifront: don't deadlock if the ring becomes full

PATCH In review David Vrabel 2 participants 3 messages Sep 11, 2014

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

PATCH 1/1 xen-scsifront: don't deadlock if the ring becomes full

scsifront_action_handler() will deadlock on host->host_lock, if the ring is full and it has to wait for entries to become available.

---
This was found with sparse. I've not tested it.

---
 drivers/scsi/xen-scsifront.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/xen-scsifront.c +2 -1
index 7e88659..cc14c8d 100644
@@ -541,8 +541,9 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
 	if (!shadow)
 		return FAILED;
 
+	spin_lock_irq(host->host_lock);
+
 	for (;;) {
-		spin_lock_irq(host->host_lock);
 		if (!RING_FULL(&info->ring)) {
 			ring_req = scsifront_command2ring(info, sc, shadow);
 			if (ring_req)
Signature · 1 line
1.7.10.4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · David Vrabel

scsifront_action_handler() will deadlock on host->host_lock, if the ring is full and it has to wait for entries to become available.

---
This was found with sparse. I've not tested it.

Test might be difficult. :-)

Thanks for spotting this.

Juergen

Quoted 20 lines
---
  drivers/scsi/xen-scsifront.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/xen-scsifront.c +2 -1
index 7e88659..cc14c8d 100644
@@ -541,8 +541,9 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
  	if (!shadow)
  		return FAILED;
 
+	spin_lock_irq(host->host_lock);
+
  	for (;;) {
-		spin_lock_irq(host->host_lock);
  		if (!RING_FULL(&info->ring)) {
  			ring_req = scsifront_command2ring(info, sc, shadow);
  			if (ring_req)
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to David Vrabel
Quoted 6 lines · David Vrabel

scsifront_action_handler() will deadlock on host->host_lock, if the ring is full and it has to wait for entries to become available.

---
This was found with sparse. I've not tested it.

Test might be difficult. :-)

Thanks for spotting this.

Juergen

Quoted 20 lines
---
  drivers/scsi/xen-scsifront.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/xen-scsifront.c +2 -1
index 7e88659..cc14c8d 100644
@@ -541,8 +541,9 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
  	if (!shadow)
  		return FAILED;
 
+	spin_lock_irq(host->host_lock);
+
  	for (;;) {
-		spin_lock_irq(host->host_lock);
  		if (!RING_FULL(&info->ring)) {
  			ring_req = scsifront_command2ring(info, sc, shadow);
  			if (ring_req)