Skip to content

Commit

Permalink
mtd/m25p80: fix test for end of loop
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
Dan Carpenter authored and David Woodhouse committed Aug 12, 2010
1 parent b06cd21 commit f78ec6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/devices/m25p80.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f78ec6b

Please sign in to comment.