gen_nand: Test if nr_chips field is valid

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Aug 12 07:59:02 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=01cd2ababddd55a127caa1cd20d570637e0d42e1
Commit:     01cd2ababddd55a127caa1cd20d570637e0d42e1
Parent:     ef56609f9c7fdf5baa9d9f86f84a7bd8a717cd25
Author:     Marek Vasut <marek.vasut at gmail.com>
AuthorDate: Thu Aug 12 03:53:55 2010 +0100
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Thu Aug 12 12:17:36 2010 +0100

    gen_nand: Test if nr_chips field is valid
    
    Signed-off-by: Marek Vasut <marek.vasut at gmail.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/plat_nand.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 90e143e..317aff4 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -37,6 +37,11 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
 	struct resource *res;
 	int err = 0;
 
+	if (pdata->chip.nr_chips < 1) {
+		dev_err(&pdev->dev, "invalid number of chips specified\n");
+		return -EINVAL;
+	}
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENXIO;



More information about the linux-mtd-cvs mailing list