[PATCH v2 06/10] staging: mt7621-mmc: Fix dereference before check in msdc_drv_pm

Christian Lütke-Stetzkamp christian at lkamp.de
Sat Apr 7 08:16:21 UTC 2018


In the msdc_drv_pm function the variable mmc is dereferenced before
checked. Reordering fixes that.

Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian at lkamp.de>
Reviewed-by: NeilBrown <neil at brown.name>
---
 drivers/staging/mt7621-mmc/sd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index ae0807b8c98f..799ec20f9820 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -2842,10 +2842,10 @@ static int msdc_drv_remove(struct platform_device *pdev)
 static void msdc_drv_pm(struct platform_device *pdev, pm_message_t 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)
-- 
2.16.1



More information about the devel mailing list