diff mbox series

[1/2] mmc: moxart: remove unneeded check for drvdata

Message ID 20200923153739.30327-1-krzk@kernel.org
State New
Headers show
Series [1/2] mmc: moxart: remove unneeded check for drvdata | expand

Commit Message

Krzysztof Kozlowski Sept. 23, 2020, 3:37 p.m. UTC
The 'struct mmc_host *mmc' comes from drvdata set at the end of probe,
so it cannot be NULL.  The code already dereferences it few lines before
the check with mmc_priv().  This also fixes smatch warning:

  drivers/mmc/host/moxart-mmc.c:692 moxart_remove() warn: variable dereferenced before check 'mmc' (see line 688)

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Comments

Ulf Hansson Sept. 24, 2020, 12:49 p.m. UTC | #1
On Wed, 23 Sep 2020 at 17:37, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>

> The 'struct mmc_host *mmc' comes from drvdata set at the end of probe,

> so it cannot be NULL.  The code already dereferences it few lines before

> the check with mmc_priv().  This also fixes smatch warning:

>

>   drivers/mmc/host/moxart-mmc.c:692 moxart_remove() warn: variable dereferenced before check 'mmc' (see line 688)

>

> Reported-by: kernel test robot <lkp@intel.com>

> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>


Applied for next, thanks!

Kind regards
Uffe


> ---

>  drivers/mmc/host/moxart-mmc.c | 23 +++++++++++------------

>  1 file changed, 11 insertions(+), 12 deletions(-)

>

> diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c

> index 2bfb376fddc4..f25079ba3bca 100644

> --- a/drivers/mmc/host/moxart-mmc.c

> +++ b/drivers/mmc/host/moxart-mmc.c

> @@ -689,19 +689,18 @@ static int moxart_remove(struct platform_device *pdev)

>

>         dev_set_drvdata(&pdev->dev, NULL);

>

> -       if (mmc) {

> -               if (!IS_ERR(host->dma_chan_tx))

> -                       dma_release_channel(host->dma_chan_tx);

> -               if (!IS_ERR(host->dma_chan_rx))

> -                       dma_release_channel(host->dma_chan_rx);

> -               mmc_remove_host(mmc);

> -               mmc_free_host(mmc);

> +       if (!IS_ERR(host->dma_chan_tx))

> +               dma_release_channel(host->dma_chan_tx);

> +       if (!IS_ERR(host->dma_chan_rx))

> +               dma_release_channel(host->dma_chan_rx);

> +       mmc_remove_host(mmc);

> +       mmc_free_host(mmc);

> +

> +       writel(0, host->base + REG_INTERRUPT_MASK);

> +       writel(0, host->base + REG_POWER_CONTROL);

> +       writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,

> +              host->base + REG_CLOCK_CONTROL);

>

> -               writel(0, host->base + REG_INTERRUPT_MASK);

> -               writel(0, host->base + REG_POWER_CONTROL);

> -               writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,

> -                      host->base + REG_CLOCK_CONTROL);

> -       }

>         return 0;

>  }

>

> --

> 2.17.1

>
diff mbox series

Patch

diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index 2bfb376fddc4..f25079ba3bca 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -689,19 +689,18 @@  static int moxart_remove(struct platform_device *pdev)
 
 	dev_set_drvdata(&pdev->dev, NULL);
 
-	if (mmc) {
-		if (!IS_ERR(host->dma_chan_tx))
-			dma_release_channel(host->dma_chan_tx);
-		if (!IS_ERR(host->dma_chan_rx))
-			dma_release_channel(host->dma_chan_rx);
-		mmc_remove_host(mmc);
-		mmc_free_host(mmc);
+	if (!IS_ERR(host->dma_chan_tx))
+		dma_release_channel(host->dma_chan_tx);
+	if (!IS_ERR(host->dma_chan_rx))
+		dma_release_channel(host->dma_chan_rx);
+	mmc_remove_host(mmc);
+	mmc_free_host(mmc);
+
+	writel(0, host->base + REG_INTERRUPT_MASK);
+	writel(0, host->base + REG_POWER_CONTROL);
+	writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
+	       host->base + REG_CLOCK_CONTROL);
 
-		writel(0, host->base + REG_INTERRUPT_MASK);
-		writel(0, host->base + REG_POWER_CONTROL);
-		writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
-		       host->base + REG_CLOCK_CONTROL);
-	}
 	return 0;
 }