<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><br>
</p>
<p></p>
<div>At the same time there are few checks such as "<span>if (host->slot)</span>" in dw_mci_runtime_resume() and commit 4a835afd808a3dbbac44bb399a902b822dc7445c message contains: "we previously assumed 'host->slot' could be null, null pointer judgment should
be added" and replaces "if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)" with "if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)"<br>
</div>
<div><span>So where is the truth?</span><br>
</div>
<div><br>
</div>
K<span>ind regards</span>
<p></p>
<p><span>Aleksandr<br>
</span></p>
<p><span><br>
</span></p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Ulf Hansson <ulf.hansson@linaro.org><br>
<b>Отправлено:</b> 7 марта 2024 г. 13:57:16<br>
<b>Кому:</b> Мишин Александр Борисович<br>
<b>Копия:</b> Jaehoon Chung; Wen Zhiwei; linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; lvc-project@linuxtesting.org<br>
<b>Тема:</b> Re: [PATCH] mmc: dw_mmc: Fix potential null pointer risk</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Thu, 7 Mar 2024 at 09:53, Aleksandr Mishin <amishin@t-argos.ru> wrote:<br>
><br>
> In dw_mci_runtime_resume() 'host->slot' could be null, but check is not cover all corresponding code.<br>
> Fix this bug by changing check place.<br>
<br>
In fact host->slot can never be NULL in dw_mci_runtime_resume() or in<br>
dw_mci_runtime_suspend().<br>
<br>
A better fix would thus be to remove the redundant checks.<br>
<br>
Kind regards<br>
Uffe<br>
<br>
><br>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.<br>
><br>
> Fixes: 4a835afd808a (mmc: dw_mmc: Fix potential null pointer risk)<br>
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru><br>
> ---<br>
> drivers/mmc/host/dw_mmc.c | 4 +++-<br>
> 1 file changed, 3 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c<br>
> index 829af2c98a44..a4f124452abc 100644<br>
> --- a/drivers/mmc/host/dw_mmc.c<br>
> +++ b/drivers/mmc/host/dw_mmc.c<br>
> @@ -3570,8 +3570,10 @@ int dw_mci_runtime_resume(struct device *dev)<br>
> DW_MCI_ERROR_FLAGS);<br>
> mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);<br>
><br>
> + if (!host->slot)<br>
> + goto err;<br>
><br>
> - if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)<br>
> + if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)<br>
> dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);<br>
><br>
> /* Force setup bus to guarantee available clock output */<br>
> --<br>
> 2.30.2<br>
><br>
><br>
</div>
</span></font>
</body>
</html>