Skip to contentSkip to conversation

mmc: sdhci: Check that ops are defined

PATCH In review Ramon Fried 3 participants 3 messages May 14, 2018 – May 15, 2018 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: Check that ops are defined

The check is necessary to avoid NULL pointer dereference.

---
 drivers/mmc/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/sdhci.c +2 -2
index 8971a1122c..400f87e134 100644
@@ -314,7 +314,7 @@ static int sdhci_execute_tuning(struct udevice *dev, uint opcode)
 
 	debug("%s\n", __func__);
 
-	if (host->ops->platform_execute_tuning) {
+	if (host->ops && host->ops->platform_execute_tuning) {
 		err = host->ops->platform_execute_tuning(mmc, opcode);
 		if (err)
 			return err;
@@ -347,7 +347,7 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)
 	if (clock == 0)
 		return 0;
 
-	if (host->ops->set_delay)
+	if (host->ops && host->ops->set_delay)
 		host->ops->set_delay(host);
 
 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 mmc: sdhci: Check that ops are defined

Quoted 22 lines · Ramon Fried

The check is necessary to avoid NULL pointer dereference.

---
 drivers/mmc/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 8971a1122c..400f87e134 100644
@@ -314,7 +314,7 @@ static int sdhci_execute_tuning(struct udevice *dev, uint opcode)
 
 	debug("%s\n", __func__);
 
-	if (host->ops->platform_execute_tuning) {
+	if (host->ops && host->ops->platform_execute_tuning) {
 		err = host->ops->platform_execute_tuning(mmc, opcode);
 		if (err)
 			return err;

drivers/mmc/sdhci.c static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) · line 353

Quoted 8 lines
drivers/mmc/sdhci.c +1 -1
@@ -347,7 +347,7 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)
 	if (clock == 0)
 		return 0;
 
-	if (host->ops->set_delay)
+	if (host->ops && host->ops->set_delay)
 		host->ops->set_delay(host);
 
 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
Fixes ca992e82e4e3 ("mmc: sdhci: Invoke platform specific tuning and

delay routines")

Tom: Can you please pick this directly?

Some drivers are not filling host->ops that's why access cause a hang. Also it is kind of interesting that travis didn't show any issue.

Thanks,
Michal

#2 lore raw
In reply to Ramon Fried
Quoted 4 lines · Ramon Fried

The check is necessary to avoid NULL pointer dereference.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180515/0cdbcac8/attachment.sig>