linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: nguyenb@codeaurora.org
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	linux-mmc@vger.kernel.org, Asutosh Das <asutoshd@codeaurora.org>,
	cang@codeaurora.org,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>
Subject: Re: [<PATCH v1> 1/4] mmc: core: Add check for NULL pointer access
Date: Thu, 05 Mar 2020 19:38:24 -0800	[thread overview]
Message-ID: <fd4bdb88d984a4095215347bc6e80afe@codeaurora.org> (raw)
In-Reply-To: <CAPDyKFrGmXj8HWNz2irUd7i8Cb77U8rLM=V91vcrWE+r7Pqeyg@mail.gmail.com>

On 2020-02-27 22:46, Ulf Hansson wrote:
> On Thu, 27 Feb 2020 at 23:06, Bao D. Nguyen <nguyenb@codeaurora.org> 
> wrote:
>> 
>> If the SD card is removed, the mmc_card pointer can be set to NULL
>> by the mmc_sd_remove() function. Check mmc_card pointer to avoid NULL
>> pointer access.
>> 
>> Signed-off-by: Bao D. Nguyen <nguyenb@codeaurora.org>
>> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
>> ---
>>  drivers/mmc/core/bus.c  | 5 +++++
>>  drivers/mmc/core/core.c | 3 +++
>>  2 files changed, 8 insertions(+)
>> 
>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>> index 74de3f2..4558f51 100644
>> --- a/drivers/mmc/core/bus.c
>> +++ b/drivers/mmc/core/bus.c
>> @@ -131,6 +131,11 @@ static void mmc_bus_shutdown(struct device *dev)
>>         struct mmc_host *host = card->host;
>>         int ret;
> 
> This obviously doesn't solve anything as we have already dereferenced
> the card->host above. In other words we should hit a NULL pointer
> dereference bug then.
> 
> More exactly, how do you trigger this problem?
I am porting this fix in the older kernel version 3.4. In that version 
3.4, the pointer check was needed.
Obviously, this NULL pointer check is not helping anything here as you 
pointed out. I will remove this check and resubmit.

> 
>> 
>> +       if (!card) {
>> +               dev_dbg(dev, "%s: %s: card is NULL\n", dev_name(dev), 
>> __func__);
>> +               return;
>> +       }
>> +
>>         if (dev->driver && drv->shutdown)
>>                 drv->shutdown(card);
>> 
> 
> [...]
> 
> Kind regards
> Uffe

  reply	other threads:[~2020-03-06  3:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 22:05 [<PATCH v1> 0/4] SD card bug fixes Bao D. Nguyen
2020-02-27 22:05 ` [<PATCH v1> 1/4] mmc: core: Add check for NULL pointer access Bao D. Nguyen
2020-02-28  6:46   ` Ulf Hansson
2020-03-06  3:38     ` nguyenb [this message]
2020-03-06 10:29       ` Ulf Hansson
2020-02-27 22:05 ` [<PATCH v1> 2/4] mmc: core: Attribute the IO wait time properly in mmc_wait_for_req_done() Bao D. Nguyen
2020-02-27 22:05 ` [<PATCH v1> 3/4] mmc: core: Make host->card as NULL when card is removed Bao D. Nguyen
2020-02-27 22:05 ` [<PATCH v1> 4/4] mmc: core: update host->card after getting RCA for SD card Bao D. Nguyen

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=fd4bdb88d984a4095215347bc6e80afe@codeaurora.org \
    --to=nguyenb@codeaurora.org \
    --cc=asutoshd@codeaurora.org \
    --cc=cang@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).