[PATCH] mmc: dw_mmc: Fix potential null pointer risk

Wen Zhiwei posted 1 patch 4 years, 6 months ago
There is a newer version of this series
drivers/mmc/host/dw_mmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mmc: dw_mmc: Fix potential null pointer risk
Posted by Wen Zhiwei 4 years, 6 months ago
we previously assumed 'host->slot' could be null,
null pointer judgment should be added

Signed-off-by: Wen Zhiwei <wenzhiwei@kylinos.cn>
---
 drivers/mmc/host/dw_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index d977f34f6b55..c9dc8c168efb 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -3518,7 +3518,7 @@ int dw_mci_runtime_resume(struct device *dev)
 	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
 
 
-	if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
+	if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
 		dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
 
 	/* Force setup bus to guarantee available clock output */
-- 
2.30.0

Re: [PATCH] mmc: dw_mmc: Fix potential null pointer risk
Posted by Jaehoon Chung 4 years, 6 months ago
On 12/29/21 11:38 AM, Wen Zhiwei wrote:
> we previously assumed 'host->slot' could be null,
> null pointer judgment should be added
> 
> Signed-off-by: Wen Zhiwei <wenzhiwei@kylinos.cn>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Beset Regards,
Jaehoon Chung

> ---
>  drivers/mmc/host/dw_mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index d977f34f6b55..c9dc8c168efb 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -3518,7 +3518,7 @@ int dw_mci_runtime_resume(struct device *dev)
>  	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
>  
>  
> -	if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
> +	if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
>  		dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
>  
>  	/* Force setup bus to guarantee available clock output */
> 

Re: [PATCH] mmc: dw_mmc: Fix potential null pointer risk
Posted by Ulf Hansson 4 years, 5 months ago
On Wed, 29 Dec 2021 at 03:38, Wen Zhiwei <wenzhiwei@kylinos.cn> wrote:
>
> we previously assumed 'host->slot' could be null,
> null pointer judgment should be added
>
> Signed-off-by: Wen Zhiwei <wenzhiwei@kylinos.cn>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/dw_mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index d977f34f6b55..c9dc8c168efb 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -3518,7 +3518,7 @@ int dw_mci_runtime_resume(struct device *dev)
>         mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
>
>
> -       if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
> +       if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
>                 dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
>
>         /* Force setup bus to guarantee available clock output */
> --
> 2.30.0
>