[PATCH 2/2] mci: arasan: configure data transfer only if we actually have data

Sascha Hauer sha at pengutronix.de
Tue May 25 00:17:27 PDT 2021


On Wed, May 19, 2021 at 09:38:55AM +0200, Michael Tretter wrote:
> If we don't have any data to transfer, we must not set the block size
> and block count.
> 
> If data is NULL, accessing data to get the block size and block count is
> a NULL pointer dereference.
> 
> Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
> ---
>  drivers/mci/arasan-sdhci.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
> index 399966e8cf10..3d738774e825 100644
> --- a/drivers/mci/arasan-sdhci.c
> +++ b/drivers/mci/arasan-sdhci.c
> @@ -283,10 +283,12 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  	sdhci_set_cmd_xfer_mode(&host->sdhci, cmd, data, false, &command, &xfer);
>  
>  	sdhci_write8(&host->sdhci, SDHCI_TIMEOUT_CONTROL, TIMEOUT_VAL);
> -	sdhci_write16(&host->sdhci, SDHCI_TRANSFER_MODE, xfer);
> -	sdhci_write16(&host->sdhci, SDHCI_BLOCK_SIZE, SDHCI_DMA_BOUNDARY_512K |
> -			    SDHCI_TRANSFER_BLOCK_SIZE(data->blocksize));
> -	sdhci_write16(&host->sdhci, SDHCI_BLOCK_COUNT, data->blocks);
> +	if (data) {
> +		sdhci_write16(&host->sdhci, SDHCI_TRANSFER_MODE, xfer);
> +		sdhci_write16(&host->sdhci, SDHCI_BLOCK_SIZE,
> +			      SDHCI_DMA_BOUNDARY_512K | SDHCI_TRANSFER_BLOCK_SIZE(data->blocksize));
> +		sdhci_write16(&host->sdhci, SDHCI_BLOCK_COUNT, data->blocks);
> +	}

I also stumbled upon this already. Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list