Re: [<PATCH v1> 1/4] mmc: core: Add check for NULL pointer access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-02-27 22:46, Ulf Hansson wrote:
On Thu, 27 Feb 2020 at 23:06, Bao D. Nguyen <nguyenb@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>
Signed-off-by: Asutosh Das <asutoshd@xxxxxxxxxxxxxx>
---
 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



[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux