mtd/m25p80: fix test for end of loop
authorDan Carpenter <error27@gmail.com>
Thu, 12 Aug 2010 07:58:27 +0000 (09:58 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 12 Aug 2010 11:31:39 +0000 (12:31 +0100)
"plat_id" is always non-NULL here.  There is a zero element on the end
of the m25p_ids[] array and if we hit the end of the loop then plat_id
points to that.

This would lead to a NULL pointer dereference later on in the function.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/devices/m25p80.c

index 83c90867240f401a8975ae5aee50ecdc688fed0c..6f512b5c117b54ef0dddbe647cdfd53a52100541 100644 (file)
@@ -793,7 +793,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
                        break;
                }
 
-               if (plat_id)
+               if (i < ARRAY_SIZE(m25p_ids) - 1)
                        id = plat_id;
                else
                        dev_warn(&spi->dev, "unrecognized id %s\n", data->type);