mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aleksandr Mishin <amishin@t-argos.ru>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Wen Zhiwei <wenzhiwei@kylinos.cn>, <linux-mmc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] mmc: dw_mmc: Fix potential null pointer risk
Date: Thu, 7 Mar 2024 22:02:56 +0300	[thread overview]
Message-ID: <98dea36b-41dc-4d2e-aec6-56c849e1d58b@t-argos.ru> (raw)
In-Reply-To: <CAPDyKFoYRT=P+4L+5ciNPxEHcS7hoXPef__NQoodxkSy=39Teg@mail.gmail.com>



07.03.2024 13:57, Ulf Hansson wrote:
> On Thu, 7 Mar 2024 at 09:53, Aleksandr Mishin <amishin@t-argos.ru> wrote:
>>
>> In dw_mci_runtime_resume() 'host->slot' could be null, but check is not cover all corresponding code.
>> Fix this bug by changing check place.
> 
> In fact host->slot can never be NULL in dw_mci_runtime_resume() or in
> dw_mci_runtime_suspend().
> 
> A better fix would thus be to remove the redundant checks.
> 
> Kind regards
> Uffe
> 
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Fixes: 4a835afd808a (mmc: dw_mmc: Fix potential null pointer risk)
>> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
>> ---
>>   drivers/mmc/host/dw_mmc.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 829af2c98a44..a4f124452abc 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -3570,8 +3570,10 @@ int dw_mci_runtime_resume(struct device *dev)
>>                     DW_MCI_ERROR_FLAGS);
>>          mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
>>
>> +       if (!host->slot)
>> +               goto err;
>>
>> -       if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
>> +       if (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.2
>>
>>
> 

At the same time there are few checks such as "if (host->slot)" 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)"
So where is the truth?

-- 
Kind regadrds
Aleksandr

  reply	other threads:[~2024-03-07 19:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  8:51 Aleksandr Mishin
2024-03-07 10:57 ` Ulf Hansson
2024-03-07 19:02   ` Aleksandr Mishin [this message]
2024-03-12 11:29     ` Ulf Hansson
     [not found] <CGME20211229023827epcas1p1c62596be323776d0abad266224c299e0@epcas1p1.samsung.com>
2021-12-29  2:38 ` Wen Zhiwei
2021-12-30  8:35   ` Jaehoon Chung
2022-01-24 14:40   ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98dea36b-41dc-4d2e-aec6-56c849e1d58b@t-argos.ru \
    --to=amishin@t-argos.ru \
    --cc=jh80.chung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wenzhiwei@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®