Make sure bank-width property provided via DT is sane. Signed-off-by: Roger Quadros <rog...@ti.com> --- arch/arm/mach-omap2/gpmc.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index c713616..70cb6b0 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1219,6 +1219,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, struct resource res; unsigned long base; int ret, cs; + struct device *dev = &pdev->dev; if (of_property_read_u32(child, "reg", &cs) < 0) { dev_err(&pdev->dev, "%s has no 'reg' property\n", @@ -1284,7 +1285,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, gpmc_s.device_width = GPMC_DEVWIDTH_16BIT; break; default: - dev_err(&pdev->dev, "%s: invalid 'nand-bus-width'\n", + dev_err(dev, "%s: invalid 'nand-bus-width'\n", child->name); ret = -EINVAL; goto err; @@ -1292,10 +1293,18 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, gpmc_s.device_nand = true; } else { - ret = of_property_read_u32(child, "bank-width", - &gpmc_s.device_width); - if (ret < 0) + if (of_property_read_u32(child, "bank-width", + &gpmc_s.device_width)) { + dev_err(dev, "%s: no 'bank-width' property\n", + child->name); + goto err; + } + + if (gpmc_s.device_width < 1 || gpmc_s.device_width > 2) { + dev_err(dev, "%s: invalid 'bank-width'\n", + child->name); goto err; + } } ret = gpmc_cs_program_settings(cs, &gpmc_s); -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/