Skip to contentSkip to conversation

mmc: avoid garbage when dt properties missing

PATCH New James Cameron 1 participant 1 message Apr 19, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: avoid garbage when dt properties missing

When of_property_read_u32 does not find a property, it does not initialise the variable, yet we were using the uninitialised variable.

Found and reproduced in sdhci-pxav3.c, on wider review found also in two other places in drivers/mmc/host/, did not review wider.

---
 drivers/mmc/host/omap_hsmmc.c  | 2 +-
 drivers/mmc/host/sdhci-pxav2.c | 4 ++--
 drivers/mmc/host/sdhci-pxav3.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -1
index e91ee21..21ff9aa 100644
@@ -1784,7 +1784,7 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
 {
 	struct omap_mmc_platform_data *pdata;
 	struct device_node *np = dev->of_node;
-	u32 bus_width, max_freq;
+	u32 bus_width = 0, max_freq;
 	int cd_gpio, wp_gpio;
 
 	cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
drivers/mmc/host/sdhci-pxav2.c +2 -2
index d51e061..10bb29b 100644
@@ -130,8 +130,8 @@ static struct sdhci_pxa_platdata *pxav2_get_mmc_pdata(struct device *dev)
 {
 	struct sdhci_pxa_platdata *pdata;
 	struct device_node *np = dev->of_node;
-	u32 bus_width;
-	u32 clk_delay_cycles;
+	u32 bus_width = 0;
+	u32 clk_delay_cycles = 0;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
drivers/mmc/host/sdhci-pxav3.c +1 -1
index 2fd73b3..d2baa15 100644
@@ -253,7 +253,7 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
 {
 	struct sdhci_pxa_platdata *pdata;
 	struct device_node *np = dev->of_node;
-	u32 clk_delay_cycles;
+	u32 clk_delay_cycles = 0;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
Signature · 6 lines
1.8.3.2


-- 
James Cameron
http://quozl.linux.org.au/