staging: mt7621-mmc: Fix dereference before check in msdc_drv_pm
authorChristian Lütke-Stetzkamp <christian@lkamp.de>
Tue, 24 Apr 2018 18:01:22 +0000 (20:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Apr 2018 13:36:19 +0000 (15:36 +0200)
In the msdc_drv_pm function the variable mmc is dereferenced before
checked. Reordering fixes that.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/mt7621-mmc/sd.c

index 7f6e584c7836fd01d41b1007fd8c33a4f5aad956..a3e2c97695918c4a926e981e5504c923ba67fcc6 100644 (file)
@@ -2709,10 +2709,10 @@ static int msdc_drv_remove(struct platform_device *pdev)
 static void msdc_drv_pm(struct platform_device *pdev, pm_message state)
 {
        struct mmc_host *mmc = platform_get_drvdata(pdev);
-       struct msdc_host *host = mmc_priv(mmc);
-
-       if (mmc)
+       if (mmc) {
+               struct msdc_host *host = mmc_priv(mmc);
                msdc_pm(state, (void *)host);
+       }
 }
 
 static int msdc_drv_suspend(struct platform_device *pdev, pm_message_t state)