Skip to contentSkip to conversation

mmc: atmel_sdhci: fix uninitialized pointer deref on probe

PATCH New Peng Fan 4 participants 16 messages Aug 6, 2019 – Aug 13, 2019

Subsystems (4)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
 drivers/mmc/atmel_sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +2 -2
index 4be47ba75e..d930ed8da0 100644
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
 		return -EINVAL;
 
 	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, ATMEL_SDHC_MIN_FREQ);
 	if (ret)
 		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
 	host->mmc->priv = host;
 	upriv->mmc = host->mmc;
 
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 23 lines

Subject: [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
 drivers/mmc/atmel_sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c index renamed from drivers/mmc/atmel_sdhci.c +0 -0

4be47ba75e..d930ed8da0 100644

drivers/mmc/atmel_sdhci.c +1 -0
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
 		return -EINVAL;
 
 	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev) · line 99

Quoted 10 lines
drivers/mmc/atmel_sdhci.c +1 -2
+	host->mmc->dev = dev;
 
 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, ATMEL_SDHC_MIN_FREQ);
 	if (ret)
 		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
 	host->mmc->priv = host;
 	upriv->mmc = host->mmc;

Patchset applied to mmc/master.

Thanks,
Peng.

Quoted 3 lines
drivers/mmc/atmel_sdhci.c +0 -1
--

2.16.4

author
#2 lore raw

PATCH 2/7 mmc: bcm: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Thomas Fitzsimmons <[email protected]>
---
 drivers/mmc/bcm2835_sdhci.c | 4 +++-
 drivers/mmc/bcmstb_sdhci.c  | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/bcm2835_sdhci.c +3 -1
index 08bddd410e..bf3304c4dc 100644
@@ -214,6 +214,9 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
 	host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
 	host->ops = &bcm2835_ops;
 
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
+
 	ret = sdhci_setup_cfg(&plat->cfg, host, emmc_freq, MIN_FREQ);
 	if (ret) {
 		debug("%s: Failed to setup SDHCI (err=%d)\n", __func__, ret);
@@ -221,7 +224,6 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
 	}
 
 	upriv->mmc = &plat->mmc;
-	host->mmc = &plat->mmc;
 	host->mmc->priv = host;
 
 	return sdhci_probe(dev);
drivers/mmc/bcmstb_sdhci.c +2 -1
index eef46f3af1..c14f8289e6 100644
@@ -73,6 +73,8 @@ static int sdhci_bcmstb_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 	ret = sdhci_setup_cfg(&plat->cfg, host,
 			      BCMSTB_SDHCI_MAXIMUM_CLOCK_FREQUENCY,
 			      BCMSTB_SDHCI_MINIMUM_CLOCK_FREQUENCY);
@@ -80,7 +82,6 @@ static int sdhci_bcmstb_probe(struct udevice *dev)
 		return ret;
 
 	upriv->mmc = &plat->mmc;
-	host->mmc = &plat->mmc;
 	host->mmc->priv = host;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4
author
#3 lore raw

PATCH 3/7 mmc: msm_sdhci: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Ramon Fried <[email protected]>
---
 drivers/mmc/msm_sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/msm_sdhci.c +2 -2
index 51f9e0ec05..cae42ec4ac 100644
@@ -141,12 +141,12 @@ static int msm_sdc_probe(struct udevice *dev)
 		writel(caps, host->ioaddr + SDHCI_VENDOR_SPEC_CAPABILITIES0);
 	}
 
-	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
 	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
+	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
 	if (ret)
 		return ret;
 	host->mmc->priv = &prv->host;
-	host->mmc->dev = dev;
 	upriv->mmc = host->mmc;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4
author
#4 lore raw

PATCH 4/7 mmc: pci: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
---
 drivers/mmc/pci_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/pci_mmc.c +2 -2
index 182d41637f..404264a697 100644
@@ -33,12 +33,12 @@ static int pci_mmc_probe(struct udevice *dev)
 	host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
 					      PCI_REGION_MEM);
 	host->name = dev->name;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
 	if (ret)
 		return ret;
-	host->mmc = &plat->mmc;
 	host->mmc->priv = &priv->host;
-	host->mmc->dev = dev;
 	upriv->mmc = host->mmc;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4
#5 lore raw

PATCH 4/7 mmc: pci: fix uninitialized pointer deref on probe

Quoted 5 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Quoted 8 lines
Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
---
 drivers/mmc/pci_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

drivers/mmc/pci_mmc.c static int pci_mmc_probe(struct udevice *dev) · line 37

Quoted 11 lines
drivers/mmc/pci_mmc.c +2 -0
index 182d41637f..404264a697 100644
@@ -33,12 +33,12 @@ static int pci_mmc_probe(struct udevice *dev)
        host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
                                              PCI_REGION_MEM);
        host->name = dev->name;
+       host->mmc = &plat->mmc;
+       host->mmc->dev = dev;

How about putting through three lines in a common function in mmc-uclass.c (with args 'host', dev and play) since they appear in a lot of drivers.

Regards,
Simon

author
#6 lore raw

PATCH 5/7 mmc: s5p: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Jaehoon Chung <[email protected]>
---
 drivers/mmc/s5p_sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/s5p_sdhci.c +2 -2
index 9dd0b865eb..53efa968cf 100644
@@ -204,13 +204,13 @@ static int s5p_sdhci_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 400000);
 	if (ret)
 		return ret;
 
-	host->mmc = &plat->mmc;
 	host->mmc->priv = host;
-	host->mmc->dev = dev;
 	upriv->mmc = host->mmc;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4
author
#7 lore raw

PATCH 6/7 mmc: sdhci-cadence: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Masahiro Yamada <[email protected]>
---
 drivers/mmc/sdhci-cadence.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci-cadence.c +2 -1
index 4f9338f733..4736263bf2 100644
@@ -269,12 +269,13 @@ static int sdhci_cdns_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
 	if (ret)
 		return ret;
 
 	upriv->mmc = &plat->mmc;
-	host->mmc = &plat->mmc;
 	host->mmc->priv = host;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4
#8 lore raw

PATCH 6/7 mmc: sdhci-cadence: fix uninitialized pointer deref on probe

Quoted 9 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Masahiro Yamada <[email protected]>
Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

In reply to Peng Fan

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

I can take it through atmel tree if needed.

Thanks,
Eugen

Quoted 34 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
  drivers/mmc/atmel_sdhci.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +2 -2
index 4be47ba75e..d930ed8da0 100644
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
  		return -EINVAL;
 
  	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
  	ret = sdhci_setup_cfg(&plat->cfg, host, 0, ATMEL_SDHC_MIN_FREQ);
  	if (ret)
  		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
  	host->mmc->priv = host;
  	upriv->mmc = host->mmc;
 
author
#10 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 10 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

I can take it through atmel tree if needed.

I need wait R-b and A-b for other patches in the patchset, Then PR to Tom. So please take this patch if hurry, and mark patchwork as accepted.

Thanks,
Peng.

Quoted 41 lines

Thanks,
Eugen

Quoted 18 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
  drivers/mmc/atmel_sdhci.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +0 -0
index 4be47ba75e..d930ed8da0 100644

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev) · line 94

Quoted 7 lines
drivers/mmc/atmel_sdhci.c +2 -0
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
  		return -EINVAL;
 
  	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
  	ret = sdhci_setup_cfg(&plat->cfg, host, 0,

ATMEL_SDHC_MIN_FREQ);

Quoted 9 lines
drivers/mmc/atmel_sdhci.c +0 -2
  	if (ret)
  		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
  	host->mmc->priv = host;
  	upriv->mmc = host->mmc;
 
#11 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 10 lines · Peng Fan
Quoted 10 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

Quoted 7 lines
Quoted 1 line

I can take it through atmel tree if needed.

I need wait R-b and A-b for other patches in the patchset, Then PR to Tom. So please take this patch if hurry, and mark patchwork as accepted.

As it looks to me all the other platforms have the same issue. So they are just as urgent. In this case I assume it won't take long for all of them to be taken, so, it's fine.

Just one question, why did you not move all the 4 initialization lines before the sdhci_setup_cfg ? Other drivers initialize all 4 before the call.

Eugen

Quoted 44 lines

Thanks,
Peng.

Quoted 41 lines

Thanks,
Eugen

Quoted 18 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
   drivers/mmc/atmel_sdhci.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +0 -0
index 4be47ba75e..d930ed8da0 100644

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev) · line 94

Quoted 7 lines
drivers/mmc/atmel_sdhci.c +2 -0
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
   		return -EINVAL;
 
   	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
   	ret = sdhci_setup_cfg(&plat->cfg, host, 0,

ATMEL_SDHC_MIN_FREQ);

Quoted 9 lines
drivers/mmc/atmel_sdhci.c +0 -2
   	if (ret)
   		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
   	host->mmc->priv = host;
   	upriv->mmc = host->mmc;
 
author
#12 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 25 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 10 lines · Peng Fan
Quoted 10 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

Quoted 7 lines
Quoted 1 line

I can take it through atmel tree if needed.

I need wait R-b and A-b for other patches in the patchset, Then PR to Tom. So please take this patch if hurry, and mark patchwork as accepted.

Quoted 6 lines

As it looks to me all the other platforms have the same issue. So they are just as urgent. In this case I assume it won't take long for all of them to be taken, so, it's fine.

Just one question, why did you not move all the 4 initialization lines before the sdhci_setup_cfg ? Other drivers initialize all 4 before the call.

Only dev is required to address the issue.

Regards,
Peng.

Quoted 48 lines

Eugen

Quoted 44 lines

Thanks,
Peng.

Quoted 41 lines

Thanks,
Eugen

Quoted 18 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
   drivers/mmc/atmel_sdhci.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +0 -0
index 4be47ba75e..d930ed8da0 100644

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev) · line 94

Quoted 7 lines
drivers/mmc/atmel_sdhci.c +2 -0
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
   		return -EINVAL;
 
   	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
   	ret = sdhci_setup_cfg(&plat->cfg, host, 0,

ATMEL_SDHC_MIN_FREQ);

Quoted 9 lines
drivers/mmc/atmel_sdhci.c +0 -2
   	if (ret)
   		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
   	host->mmc->priv = host;
   	upriv->mmc = host->mmc;
 
#13 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 25 lines · Peng Fan
Quoted 25 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 17 lines · Peng Fan
Quoted 11 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

I can take it through atmel tree if needed.

I need wait R-b and A-b for other patches in the patchset, Then PR to Tom. So please take this patch if hurry, and mark patchwork as accepted.

Quoted 9 lines
Quoted 6 lines

As it looks to me all the other platforms have the same issue. So they are just as urgent. In this case I assume it won't take long for all of them to be taken, so, it's fine.

Just one question, why did you not move all the 4 initialization lines before the sdhci_setup_cfg ? Other drivers initialize all 4 before the call.

Only dev is required to address the issue.

True. But other drivers perform all 4 initializations. In the future the sdhci core might again make wrong assumptions about them, and we might get another crash?
Why not move all the 4 lines now ? It looks like they are just backpointers. So I would say the initialization of the pointers is incomplete before the sdhci_setup_cfg call, would be better to do it completely

Eugen

Quoted 51 lines

Regards,
Peng.

Quoted 48 lines

Eugen

Quoted 44 lines

Thanks,
Peng.

Quoted 41 lines

Thanks,
Eugen

Quoted 18 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
    drivers/mmc/atmel_sdhci.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/atmel_sdhci.c +0 -0
index 4be47ba75e..d930ed8da0 100644

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev) · line 94

Quoted 7 lines
drivers/mmc/atmel_sdhci.c +2 -0
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
    		return -EINVAL;
 
    	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
    	ret = sdhci_setup_cfg(&plat->cfg, host, 0,

ATMEL_SDHC_MIN_FREQ);

Quoted 9 lines
drivers/mmc/atmel_sdhci.c +0 -2
    	if (ret)
    		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
    	host->mmc->priv = host;
    	upriv->mmc = host->mmc;
 
author
#14 lore raw

PATCH 1/7 mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 37 lines
Quoted 26 lines
Quoted 26 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

Quoted 17 lines · Peng Fan
Quoted 11 lines

Subject: Re: [U-Boot] [PATCH 1/7] mmc: atmel_sdhci: fix uninitialized pointer deref on probe

This has to go as soon as possible into the tree.
The at91 boards do not boot without this. The commit checking for sdhci-caps-mask introduces a crash at this point.

I can take it through atmel tree if needed.

I need wait R-b and A-b for other patches in the patchset, Then PR to Tom. So please take this patch if hurry, and mark patchwork as accepted.

Quoted 6 lines
Quoted 6 lines

As it looks to me all the other platforms have the same issue. So they are just as urgent. In this case I assume it won't take long for all of them to be taken, so, it's fine.

Just one question, why did you not move all the 4 initialization lines before the sdhci_setup_cfg ? Other drivers initialize all 4 before the

call.

Quoted 3 lines

Only dev is required to address the issue.

Quoted 6 lines

True. But other drivers perform all 4 initializations. In the future the sdhci core might again make wrong assumptions about them, and we might get another crash?
Why not move all the 4 lines now ? It looks like they are just backpointers. So I would say the initialization of the pointers is incomplete before the sdhci_setup_cfg call, would be better to do it completely

After checking the code, sdhci.c is common code, priv pointer should be not used there. So no need to move priv here.
and upriv is used by mmc uclass.

The remaining 2 has no chance to be used by sdhci.c.

Regards,
Peng.

Quoted 56 lines

Eugen

Quoted 30 lines

Regards,
Peng.

Quoted 27 lines

Eugen

Quoted 23 lines

Thanks,
Peng.

Quoted 20 lines

Thanks,
Eugen

Quoted 14 lines · Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for

sdhci-caps-mask")

Cc Faiz Abbas <[email protected]>
Cc Wenyou Yang <[email protected]>
---
    drivers/mmc/atmel_sdhci.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice

Quoted 5 lines
drivers/mmc/atmel_sdhci.c +0 -0
index 4be47ba75e..d930ed8da0 100644
@@ -88,13 +88,13 @@ static int atmel_sdhci_probe(struct udevice

*dev)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

drivers/mmc/atmel_sdhci.c static int atmel_sdhci_probe(struct udevice *dev)

Quoted 7 lines
drivers/mmc/atmel_sdhci.c +2 -0
    		return -EINVAL;
 
    	host->max_clk = max_clk;
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 
    	ret = sdhci_setup_cfg(&plat->cfg, host, 0,

ATMEL_SDHC_MIN_FREQ);

Quoted 9 lines
drivers/mmc/atmel_sdhci.c +0 -2
    	if (ret)
    		return ret;
 
-	host->mmc = &plat->mmc;
-	host->mmc->dev = dev;
    	host->mmc->priv = host;
    	upriv->mmc = host->mmc;
 
author
#15 lore raw

PATCH 7/7 mmc: tangier_sdhci: fix uninitialized pointer deref on probe

In reply to Peng Fan

Commit 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc field.

Fixes 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc Faiz Abbas <[email protected]>
Cc Vincent Tinelli <[email protected]>
---
 drivers/mmc/tangier_sdhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/tangier_sdhci.c +2 -1
index 4c33356b9f..0d6e5d6246 100644
@@ -51,13 +51,14 @@ static int sdhci_tangier_probe(struct udevice *dev)
 	/* MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195 */
 	host->voltages = MMC_VDD_165_195;
 
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
 	ret = sdhci_setup_cfg(&plat->cfg, host, SDHCI_TANGIER_FMAX,
 			SDHCI_TANGIER_FMIN);
 	if (ret)
 		return ret;
 
 	upriv->mmc = &plat->mmc;
-	host->mmc = &plat->mmc;
 	host->mmc->priv = host;
 
 	return sdhci_probe(dev);
Signature · 1 line
2.16.4