diff mbox series

mmc: sdhci-of-esdhc: fix unchecked return value issue

Message ID 1542788904-15621-1-git-send-email-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series mmc: sdhci-of-esdhc: fix unchecked return value issue | expand

Commit Message

Bough Chen Nov. 21, 2018, 8:20 a.m. UTC
Calling dma_set_mask_and_coherent without checking return value.
This was caught by coverity scan.

Fix this by check the return value, and give a warning if get a
false.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-of-esdhc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Yangbo Lu Nov. 21, 2018, 8:41 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: BOUGH CHEN
> Sent: Wednesday, November 21, 2018 4:21 PM
> To: adrian.hunter@intel.com; ulf.hansson@linaro.org;
> linux-mmc@vger.kernel.org
> Cc: Y.B. LU <yangbo.lu@nxp.com>; dl-linux-imx <linux-imx@nxp.com>; BOUGH
> CHEN <haibo.chen@nxp.com>
> Subject: [PATCH] mmc: sdhci-of-esdhc: fix unchecked return value issue
> 
> Calling dma_set_mask_and_coherent without checking return value.
> This was caught by coverity scan.
> 
> Fix this by check the return value, and give a warning if get a false.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> b/drivers/mmc/host/sdhci-of-esdhc.c
> index 86fc9f0..bfba630 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -478,8 +478,13 @@ static int esdhc_of_enable_dma(struct sdhci_host
> *host)
>  	struct device *dev = mmc_dev(host->mmc);
> 
>  	if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
> -	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
> -		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
> +	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
> +		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));

[Y.b. Lu] You just forgot to define ret. The changes make sense for me.
You can add my ACK in next version.
Acked-by: Yangbo Lu <Yangbo.lu@nxp.com>

> +		if (ret) {
> +			pr_warn("%s: Failed to set 40-bit DMA mask.\n",
> +				mmc_hostname(host->mmc));
> +		}
> +	}
> 
>  	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>  	value |= ESDHC_DMA_SNOOP;
> --
> 1.9.1
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 86fc9f0..bfba630 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -478,8 +478,13 @@  static int esdhc_of_enable_dma(struct sdhci_host *host)
 	struct device *dev = mmc_dev(host->mmc);
 
 	if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
-	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
-		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+		if (ret) {
+			pr_warn("%s: Failed to set 40-bit DMA mask.\n",
+				mmc_hostname(host->mmc));
+		}
+	}
 
 	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
 	value |= ESDHC_DMA_SNOOP;