Skip to contentSkip to conversation

ib_srp: Test once whether iu allocation succeeded

PATCH In review Bart Van Assche 3 participants 3 messages Jan 13, 2011 1 message not in the archive

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

PATCH 1/1 ib_srp: Test once whether iu allocation succeeded

Merge the two tests whether information unit allocation succeeded into one. An intended side effect of this change is that gcc 4.4.4 does no longer complain that the variable 'req' might be used uninitialized in the function srp_queuecommand() when ib_srp is built with CONFIG_CC_OPTIMIZE_FOR_SIZE=y. This was reported by Roland Dreier.

---
 drivers/infiniband/ulp/srp/ib_srp.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +6 -8
index 4b62105..72d1b96 100644
@@ -1132,15 +1132,11 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 
 	spin_lock_irqsave(&target->lock, flags);
 	iu = __srp_get_tx_iu(target, SRP_IU_CMD);
-	if (iu) {
-		req = list_first_entry(&target->free_reqs, struct srp_request,
-				      list);
-		list_del(&req->list);
-	}
-	spin_unlock_irqrestore(&target->lock, flags);
-
 	if (!iu)
-		goto err;
+		goto err_unlock;
+	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, srp_max_iu_len,
@@ -1185,6 +1181,8 @@ err_iu:
 
 	spin_lock_irqsave(&target->lock, flags);
 	list_add(&req->list, &target->free_reqs);
+
+err_unlock:
 	spin_unlock_irqrestore(&target->lock, flags);
 
 err:
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
In reply to a message not in the archive
Quoted 5 lines · Bart Van Assche

Merge the two tests whether information unit allocation succeeded into one. An intended side effect of this change is that gcc 4.4.4 does no longer complain that the variable 'req' might be used uninitialized in the function srp_queuecommand() when ib_srp is built with CONFIG_CC_OPTIMIZE_FOR_SIZE=y. This was reported by Roland Dreier.

Thanks Bart,
Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html