aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-04-13 16:47:01 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 07:04:12 -0400
commit976d9276c826d6b35e4a2478fd4978dbd63bdd6f (patch)
tree0d90e7f4c96a850503776218fec74db1ead46963
parent14d836e7499c53a1f6a65086c3d11600e871a971 (diff)
mmc: enforce correct sg list
Now that we've fixed our only offender when it comes to strange sg list, add a check so that future users keep the sg list proper with regard to transfer size. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
-rw-r--r--drivers/mmc/mmc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 4a73e8b2428d..e8f896c61b34 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -99,6 +99,10 @@ EXPORT_SYMBOL(mmc_request_done);
99void 99void
100mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) 100mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
101{ 101{
102#ifdef CONFIG_MMC_DEBUG
103 unsigned int i, sz;
104#endif
105
102 pr_debug("%s: starting CMD%u arg %08x flags %08x\n", 106 pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
103 mmc_hostname(host), mrq->cmd->opcode, 107 mmc_hostname(host), mrq->cmd->opcode,
104 mrq->cmd->arg, mrq->cmd->flags); 108 mrq->cmd->arg, mrq->cmd->flags);
@@ -113,6 +117,13 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
113 BUG_ON(mrq->data->blocks * mrq->data->blksz > 117 BUG_ON(mrq->data->blocks * mrq->data->blksz >
114 host->max_req_size); 118 host->max_req_size);
115 119
120#ifdef CONFIG_MMC_DEBUG
121 sz = 0;
122 for (i = 0;i < mrq->data->sg_len;i++)
123 sz += mrq->data->sg[i].length;
124 BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
125#endif
126
116 mrq->cmd->data = mrq->data; 127 mrq->cmd->data = mrq->data;
117 mrq->data->error = 0; 128 mrq->data->error = 0;
118 mrq->data->mrq = mrq; 129 mrq->data->mrq = mrq;