diff options
author | Nicolas Ferre <nicolas.ferre@atmel.com> | 2010-05-11 17:06:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-11 20:33:41 -0400 |
commit | 009a891b22395fc86e5f34057d79fffee4509ab5 (patch) | |
tree | d481fdd81ce2e0c561dd22b07cae998ee9d0b72c /drivers/mmc/host/atmel-mci.c | |
parent | ebb1fea9b3adf25d7e2f643c614163af4f93a17f (diff) |
mmc: atmel-mci: prevent kernel oops while removing card
The removing of an SD card in certain circumstances can lead to a kernel
oops if we do not make sure that the "data" field of the host structure is
valid. This patch adds a test in atmci_dma_cleanup() function and also
calls atmci_stop_dma() before throwing away the reference to data.
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: <linux-mmc@vger.kernel.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/host/atmel-mci.c')
-rw-r--r-- | drivers/mmc/host/atmel-mci.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 57d3cb2dbb5f..2a5d5cafeb5f 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -569,9 +569,10 @@ static void atmci_dma_cleanup(struct atmel_mci *host) | |||
569 | { | 569 | { |
570 | struct mmc_data *data = host->data; | 570 | struct mmc_data *data = host->data; |
571 | 571 | ||
572 | dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, | 572 | if (data) |
573 | ((data->flags & MMC_DATA_WRITE) | 573 | dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, |
574 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); | 574 | ((data->flags & MMC_DATA_WRITE) |
575 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); | ||
575 | } | 576 | } |
576 | 577 | ||
577 | static void atmci_stop_dma(struct atmel_mci *host) | 578 | static void atmci_stop_dma(struct atmel_mci *host) |
@@ -1099,8 +1100,8 @@ static void atmci_command_complete(struct atmel_mci *host, | |||
1099 | "command error: status=0x%08x\n", status); | 1100 | "command error: status=0x%08x\n", status); |
1100 | 1101 | ||
1101 | if (cmd->data) { | 1102 | if (cmd->data) { |
1102 | host->data = NULL; | ||
1103 | atmci_stop_dma(host); | 1103 | atmci_stop_dma(host); |
1104 | host->data = NULL; | ||
1104 | mci_writel(host, IDR, MCI_NOTBUSY | 1105 | mci_writel(host, IDR, MCI_NOTBUSY |
1105 | | MCI_TXRDY | MCI_RXRDY | 1106 | | MCI_TXRDY | MCI_RXRDY |
1106 | | ATMCI_DATA_ERROR_FLAGS); | 1107 | | ATMCI_DATA_ERROR_FLAGS); |