Skip to contentSkip to conversation

mmc: block: fixed NULL pointer dereference

PATCH In review Jaehoon Chung 2 participants 2 messages Jul 13, 2011 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: block: fixed NULL pointer dereference

Hi.

I send to mailing for [RFC] Kernel NULL pointer dereference. This patch is fixed it.

In similar case, when discard request, check condition and performed mmc_blk_issue_rw_rq(mq, NULL) for ongoing async transfer.

But When flush request, entered the mmc_blk_issue_flush() then return. (then didn't complete ongoing aync transfer).

I think that need to complete for ongoing aync transfer before flush request.

I tested with this patch, it's working fine.
(SDHCI controller, eMMC4.41)

---
 drivers/mmc/card/block.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +3 -0
index 38d0149..1ff5486 100644
@@ -1200,6 +1200,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 		else
 			ret = mmc_blk_issue_discard_rq(mq, req);
 	} else if (req && req->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_flush(mq, req);
 	} else {
 		ret = mmc_blk_issue_rw_rq(mq, req);
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jaehoon Chung

Hi.

I send to mailing for [RFC] Kernel NULL pointer dereference. This patch is fixed it.

Quoted 8 lines

In similar case, when discard request, check condition and performed mmc_blk_issue_rw_rq(mq, NULL) for ongoing async transfer.

But When flush request, entered the mmc_blk_issue_flush() then return. (then didn't complete ongoing aync transfer).

I think that need to complete for ongoing aync transfer before flush request.

I did consider this when I added the check for discard but I didn't realize it is necessary for flush too.
There is no real downside of completing the async request before flush in terms of performance anyway.

Thanks for catching this bug.

Quoted 7 lines
(quoted diff) +0 -0
@@ -1200,6 +1200,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)

               else
                       ret = mmc_blk_issue_discard_rq(mq, req); } else if (req && req->cmd_flags & REQ_FLUSH) {
+               /* complete ongoing async transfer before issuing flush */
+               if (card->host->areq)
+                       mmc_blk_issue_rw_rq(mq, NULL);

These 2 lines are the same as for the discard condition. I still prefer 2 lines of repeating code rather than one big if-statement covering both discard and flush.

Regards,
Per