Skip to contentSkip to conversation

mmc:Fix error handling in the function mmc_blk_issue_rq

PATCH RESEND Adrian Hunter 1 participant 1 message Dec 28, 2015 1 message not in the archive MMC, SD and SDIO

lore
Share & tools
lore

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

#1 lore raw
Quoted 7 lines · Nicholas Krause

This fixes error handling in the function mmc_blk_issue_rq for checking if the calls to the function mmc_blk_issue_rw_rq have failed by returning zero as there return value and if so jump immediately to the goto label out for cleanup of resources used and allocated by the function mmc_blk_issue_rq before returning this return value to the caller of this particular function to indicate to the caller that it's call(s) have failed.

Are you experiencing a problem with the existing code, because it looks more correct to me?

There does seem to be a gap in the way MMC_QUEUE_NEW_REQUEST is handled, since the code is expecting that mmc_blk_issue_rw_rq() will have done waiting for any ongoing request, but it is not clear it will have if MMC_QUEUE_NEW_REQUEST is possible. But that is a different issue.

Quoted 33 lines
---
 drivers/mmc/card/block.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +6 -2
index a1b820f..354a151 100644
@@ -2055,7 +2055,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 	if (cmd_flags & REQ_DISCARD) {
 		/* complete ongoing async transfer before issuing discard */
 		if (card->host->areq)
-			mmc_blk_issue_rw_rq(mq, NULL);
+			ret = mmc_blk_issue_rw_rq(mq, NULL);
+		if (!ret)
+			goto out;
 		if (req->cmd_flags & REQ_SECURE)
 			ret = mmc_blk_issue_secdiscard_rq(mq, req);
 		else
@@ -2063,7 +2065,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 	} else if (cmd_flags & REQ_FLUSH) {
 		/* complete ongoing async transfer before issuing flush */
 		if (card->host->areq)
-			mmc_blk_issue_rw_rq(mq, NULL);
+			ret = mmc_blk_issue_rw_rq(mq, NULL);
+		if (!ret)
+			goto out;
 		ret = mmc_blk_issue_flush(mq, req);
 	} else {
 		if (!req && host->areq) {