mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 10:49:28 +00:00
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>
This commit is contained in:
parent
ebb1fea9b3
commit
009a891b22
1 changed files with 5 additions and 4 deletions
|
@ -569,9 +569,10 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
|
||||||
{
|
{
|
||||||
struct mmc_data *data = host->data;
|
struct mmc_data *data = host->data;
|
||||||
|
|
||||||
dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len,
|
if (data)
|
||||||
((data->flags & MMC_DATA_WRITE)
|
dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len,
|
||||||
? DMA_TO_DEVICE : DMA_FROM_DEVICE));
|
((data->flags & MMC_DATA_WRITE)
|
||||||
|
? DMA_TO_DEVICE : DMA_FROM_DEVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void atmci_stop_dma(struct atmel_mci *host)
|
static void atmci_stop_dma(struct atmel_mci *host)
|
||||||
|
@ -1099,8 +1100,8 @@ static void atmci_command_complete(struct atmel_mci *host,
|
||||||
"command error: status=0x%08x\n", status);
|
"command error: status=0x%08x\n", status);
|
||||||
|
|
||||||
if (cmd->data) {
|
if (cmd->data) {
|
||||||
host->data = NULL;
|
|
||||||
atmci_stop_dma(host);
|
atmci_stop_dma(host);
|
||||||
|
host->data = NULL;
|
||||||
mci_writel(host, IDR, MCI_NOTBUSY
|
mci_writel(host, IDR, MCI_NOTBUSY
|
||||||
| MCI_TXRDY | MCI_RXRDY
|
| MCI_TXRDY | MCI_RXRDY
|
||||||
| ATMCI_DATA_ERROR_FLAGS);
|
| ATMCI_DATA_ERROR_FLAGS);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue