提交 f78ec6b2 编写于 作者: D Dan Carpenter 提交者: David Woodhouse

mtd/m25p80: fix test for end of loop

"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: NDan Carpenter <error27@gmail.com>
Acked-by: NAnton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 b06cd21e
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册