Skip to content

Commit 51f7ea9

Browse files
committed
Merge tag 'mmc-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Fix support for SD Power off notification MMC host: - moxart: Fix potential use-after-free on remove path - sdhci-of-esdhc: Fix error path when setting dma mask - sh_mmcif: Fix potential NULL pointer dereference" * tag 'mmc-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: moxart: fix potential use-after-free on remove path mmc: core: Wait for command setting 'Power Off Notification' bit to complete mmc: sh_mmcif: Check for null res pointer mmc: sdhci-of-esdhc: Check for error num after setting mask
2 parents c8ba56b + bd2db32 commit 51f7ea9

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

drivers/mmc/core/sd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const unsigned int sd_au_size[] = {
6767
__res & __mask; \
6868
})
6969

70-
#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 2000
70+
#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 1000
7171
#define SD_WRITE_EXTR_SINGLE_TIMEOUT_MS 1000
7272

7373
struct sd_busy_data {
@@ -1664,6 +1664,12 @@ static int sd_poweroff_notify(struct mmc_card *card)
16641664
goto out;
16651665
}
16661666

1667+
/* Find out when the command is completed. */
1668+
err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false,
1669+
MMC_BUSY_EXTR_SINGLE);
1670+
if (err)
1671+
goto out;
1672+
16671673
cb_data.card = card;
16681674
cb_data.reg_buf = reg_buf;
16691675
err = __mmc_poll_for_busy(card->host, SD_POWEROFF_NOTIFY_TIMEOUT_MS,

drivers/mmc/host/moxart-mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,12 @@ static int moxart_remove(struct platform_device *pdev)
705705
if (!IS_ERR_OR_NULL(host->dma_chan_rx))
706706
dma_release_channel(host->dma_chan_rx);
707707
mmc_remove_host(mmc);
708-
mmc_free_host(mmc);
709708

710709
writel(0, host->base + REG_INTERRUPT_MASK);
711710
writel(0, host->base + REG_POWER_CONTROL);
712711
writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
713712
host->base + REG_CLOCK_CONTROL);
713+
mmc_free_host(mmc);
714714

715715
return 0;
716716
}

drivers/mmc/host/sdhci-of-esdhc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,16 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
524524

525525
static int esdhc_of_enable_dma(struct sdhci_host *host)
526526
{
527+
int ret;
527528
u32 value;
528529
struct device *dev = mmc_dev(host->mmc);
529530

530531
if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
531-
of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
532-
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
532+
of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
533+
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
534+
if (ret)
535+
return ret;
536+
}
533537

534538
value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
535539

drivers/mmc/host/sh_mmcif.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ static int sh_mmcif_dma_slave_config(struct sh_mmcif_host *host,
405405
struct dma_slave_config cfg = { 0, };
406406

407407
res = platform_get_resource(host->pd, IORESOURCE_MEM, 0);
408+
if (!res)
409+
return -EINVAL;
410+
408411
cfg.direction = direction;
409412

410413
if (direction == DMA_DEV_TO_MEM) {

0 commit comments

Comments
 (0)