mmc: renesas_sdhi: Add missing checks for the presence of quirks
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 1 Apr 2022 14:09:28 +0000 (16:09 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 26 Apr 2022 12:05:18 +0000 (14:05 +0200)
When running on an system without any quirks (e.g. R-Car V3U), the
kernel crashes with a NULL pointer dereference:

    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000002
    ...
    Hardware name: Renesas Falcon CPU and Breakout boards based on r8a779a0 (DT)
    Workqueue: events_freezable mmc_rescan
    ...
    Call trace:
     renesas_sdhi_internal_dmac_start_dma+0x54/0x12c
     tmio_process_mrq+0x124/0x274

Fix this by adding the missing checks for the validatity of the
priv->quirks pointer.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/cc3178c2ff60f640f4d5a071d51f6b0b1db37656.1648822020.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi_internal_dmac.c

index 0bf35fb8b293975f22b8e9b9f8b5c0f0326f5404..9dd01c220e9305f94b0c6f8fa6c5f90bfe165b07 100644 (file)
@@ -372,7 +372,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
        struct scatterlist *sg = host->sg_ptr;
        u32 dtran_mode = DTRAN_MODE_BUS_WIDTH;
 
-       if (!priv->quirks->fixed_addr_mode)
+       if (!(priv->quirks && priv->quirks->fixed_addr_mode))
                dtran_mode |= DTRAN_MODE_ADDR_MODE;
 
        if (!renesas_sdhi_internal_dmac_map(host, data, COOKIE_MAPPED))
@@ -380,7 +380,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
 
        if (data->flags & MMC_DATA_READ) {
                dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
-               if (priv->quirks->dma_one_rx_only &&
+               if (priv->quirks && priv->quirks->dma_one_rx_only &&
                    test_and_set_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags))
                        goto force_pio_with_unmap;
        } else {