mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pan Zhang <zhangpan26@huawei.com>
To: <ulf.hansson@linaro.org>, <p.zabel@pengutronix.de>,
	<jh80.chung@samsung.com>, <zhangpan26@huawei.com>,
	<hushiyuan@huawei.com>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH] mmc: host: fix a possible null pointer access.
Date: Thu, 19 Dec 2019 14:28:09 +0800	[thread overview]
Message-ID: <1576736889-4430-1-git-send-email-zhangpan26@huawei.com> (raw)
In-Reply-To: <CAPDyKFr8aVWVydT5U6mpuZr5_waH=bn6F8rjryfDJ15FDaAXUw@mail.gmail.com>

On Wed, 18 Dec 2019 at 7:52 p.m., Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>
>> 3419     if (host->slot &&
>> 3420         (mmc_can_gpio_cd(host->slot->mmc) ||
>> 3421          !mmc_card_is_removable(host->slot->mmc))) {
>> 3422         ret = clk_prepare_enable(host->biu_clk);
>> 3423         if (ret)
>> 3424             return ret;
>> 3425     }
>>
>> We previously assumed 'host->slot' could be null (see line 3419).
>>
>> The following situation is similar, so add a judgement.
>>
>> Signed-off-by: Pan Zhang <zhangpan26@huawei.com>
>> ---
>>  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 fc9d4d0..8e27c52 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -3454,7 +3454,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);

>This shouldn't be a problem as the ->runtime_resume() callback can't be invoked, unless there is a slot.

>>
>>         /* Force setup bus to guarantee available clock output */
>> --
>> 2.7.4
>>

If so, there is no need to assume host->slot pointer previously(line 3419)?


  reply	other threads:[~2019-12-19  6:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17  3:17 Pan Zhang
2019-12-18 11:52 ` Ulf Hansson
2019-12-19  6:28   ` Pan Zhang [this message]
2019-12-19  7:07     ` 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=1576736889-4430-1-git-send-email-zhangpan26@huawei.com \
    --to=zhangpan26@huawei.com \
    --cc=hushiyuan@huawei.com \
    --cc=jh80.chung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=ulf.hansson@linaro.org \
    /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®