[PATCH v1 1/3] mmc: msm_sdhci: fix max-frequency read into wrong-sized variable
Aswin Murugan <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
msm_sdc_clk_init() reads the "max-frequency" DT property with dev_read_u32(dev, "max-frequency", (uint *)(&clk_rate)), writing only 4 bytes into clk_rate, an 8-byte ulong. The upper 4 bytes are left uninitialized whenever the property is present. Read into a u32 local instead, then assign it to clk_rate. Signed-off-by: Aswin Murugan <[email protected]> --- drivers/mmc/msm_sdhci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index 7bdb02142a2..cbf565be426 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -65,12 +65,15 @@ static int msm_sdc_clk_init(struct udevice *dev) struct msm_sdhc *prv = dev_get_priv(dev); const struct msm_sdhc_variant_info *var_info; ulong clk_rate; + u32 max_frequency; int ret, i = 0, n_clks; const char *clk_name; var_info = (void *)dev_get_driver_data(dev); - if (dev_read_u32(dev, "max-frequency", (uint *)(&clk_rate))) + if (!dev_read_u32(node, "max-frequency", &max_frequency)) + clk_rate = max_frequency; + else clk_rate = 201500000; ret = clk_get_bulk(dev, &prv->clks); -- 2.34.1