mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: bcm2835: Set mci host for sdhci
@ 2024-05-22  6:15 Jonas Richardsen
  2024-05-22  8:08 ` Ahmad Fatoum
  2024-05-24 11:43 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jonas Richardsen @ 2024-05-22  6:15 UTC (permalink / raw)
  To: barebox; +Cc: Jonas Richardsen

The pointer `sdhci.mci` is currently not being set for the bcm2835. This
leads to a null pointer dereference for example in `sdhci_wait_idle()`
if the `sdhci_read` function fails or times out.

Set the pointer within the `bcm2835_mci_probe` function. This is
analogous to the behaviour seen in `arasan_sdhci_probe`,
`fsl_esdhc_probe`, `rk_sdhci_probe` and other, similar functions.

Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com>
---
 drivers/mci/mci-bcm2835.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index 3546cc3a32..7fcf4f905b 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -382,6 +382,7 @@ static int bcm2835_mci_probe(struct device *hw_dev)
 	host->hw_dev = hw_dev;
 	host->max_clock = clk_get_rate(clk);
 
+	host->sdhci.mci = &host->mci;
 	host->sdhci.read32 = bcm2835_sdhci_read32;
 	host->sdhci.write32 = bcm2835_sdhci_write32;
 
-- 
2.42.0




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

* Re: [PATCH] mci: bcm2835: Set mci host for sdhci
  2024-05-22  6:15 [PATCH] mci: bcm2835: Set mci host for sdhci Jonas Richardsen
@ 2024-05-22  8:08 ` Ahmad Fatoum
  2024-05-24 11:43 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-22  8:08 UTC (permalink / raw)
  To: Jonas Richardsen, barebox

On 22.05.24 08:15, Jonas Richardsen wrote:
> The pointer `sdhci.mci` is currently not being set for the bcm2835. This
> leads to a null pointer dereference for example in `sdhci_wait_idle()`
> if the `sdhci_read` function fails or times out.
> 
> Set the pointer within the `bcm2835_mci_probe` function. This is
> analogous to the behaviour seen in `arasan_sdhci_probe`,
> `fsl_esdhc_probe`, `rk_sdhci_probe` and other, similar functions.
> 
> Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com>

Good catch. I think this should go into master:

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

This unearths some further improvement opportunities. See the series
I just Cc'd you on.

Thanks,
Ahmad

> ---
>  drivers/mci/mci-bcm2835.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
> index 3546cc3a32..7fcf4f905b 100644
> --- a/drivers/mci/mci-bcm2835.c
> +++ b/drivers/mci/mci-bcm2835.c
> @@ -382,6 +382,7 @@ static int bcm2835_mci_probe(struct device *hw_dev)
>  	host->hw_dev = hw_dev;
>  	host->max_clock = clk_get_rate(clk);
>  
> +	host->sdhci.mci = &host->mci;
>  	host->sdhci.read32 = bcm2835_sdhci_read32;
>  	host->sdhci.write32 = bcm2835_sdhci_write32;
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] mci: bcm2835: Set mci host for sdhci
  2024-05-22  6:15 [PATCH] mci: bcm2835: Set mci host for sdhci Jonas Richardsen
  2024-05-22  8:08 ` Ahmad Fatoum
@ 2024-05-24 11:43 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-05-24 11:43 UTC (permalink / raw)
  To: barebox, Jonas Richardsen


On Wed, 22 May 2024 08:15:27 +0200, Jonas Richardsen wrote:
> The pointer `sdhci.mci` is currently not being set for the bcm2835. This
> leads to a null pointer dereference for example in `sdhci_wait_idle()`
> if the `sdhci_read` function fails or times out.
> 
> Set the pointer within the `bcm2835_mci_probe` function. This is
> analogous to the behaviour seen in `arasan_sdhci_probe`,
> `fsl_esdhc_probe`, `rk_sdhci_probe` and other, similar functions.
> 
> [...]

Applied, thanks!

[1/1] mci: bcm2835: Set mci host for sdhci
      https://git.pengutronix.de/cgit/barebox/commit/?id=5d74c69b3279 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-05-24 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22  6:15 [PATCH] mci: bcm2835: Set mci host for sdhci Jonas Richardsen
2024-05-22  8:08 ` Ahmad Fatoum
2024-05-24 11:43 ` Sascha Hauer

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