public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mmc: sdhci: Check that ops are defined
@ 2018-05-14 12:02 Ramon Fried
  2018-05-14 13:28 ` Michal Simek
  2018-05-15 12:28 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Ramon Fried @ 2018-05-14 12:02 UTC (permalink / raw)
  To: u-boot

The check is necessary to avoid NULL pointer dereference.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
 drivers/mmc/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 8971a1122c..400f87e134 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -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) {
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] mmc: sdhci: Check that ops are defined
  2018-05-14 12:02 [U-Boot] [PATCH] mmc: sdhci: Check that ops are defined Ramon Fried
@ 2018-05-14 13:28 ` Michal Simek
  2018-05-15 12:28 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2018-05-14 13:28 UTC (permalink / raw)
  To: u-boot

On 14.5.2018 14:02, Ramon Fried wrote:
> The check is necessary to avoid NULL pointer dereference.
> 
> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> ---
>  drivers/mmc/sdhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 8971a1122c..400f87e134 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -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) {
> 

Reviewed-by: Michal Simek <michal.simek@xilinx.com>
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] mmc: sdhci: Check that ops are defined
  2018-05-14 12:02 [U-Boot] [PATCH] mmc: sdhci: Check that ops are defined Ramon Fried
  2018-05-14 13:28 ` Michal Simek
@ 2018-05-15 12:28 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2018-05-15 12:28 UTC (permalink / raw)
  To: u-boot

On Mon, May 14, 2018 at 03:02:30PM +0300, Ramon Fried wrote:

> The check is necessary to avoid NULL pointer dereference.
> 
> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-15 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-14 12:02 [U-Boot] [PATCH] mmc: sdhci: Check that ops are defined Ramon Fried
2018-05-14 13:28 ` Michal Simek
2018-05-15 12:28 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox