From: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx> Expand the spi_nor_check() to make sure that nor->spimem and nor->controller_ops are mutual exclusive. Fixes: b35b9a10362d ("mtd: spi-nor: Move m25p80 code in spi-nor.c") Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Signed-off-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx> --- v2: new patch drivers/mtd/spi-nor/spi-nor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index a6f9f833c862..b452d3d0de28 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2741,6 +2741,12 @@ static int spi_nor_check(struct spi_nor *nor) return -EINVAL; } + if ((nor->spimem && nor->controller_ops) || + (!nor->spimem && !nor->controller_ops)) { + dev_err(nor->dev, "nor->spimem and nor->controller_ops are mutual exclusive\n"); + return -EINVAL; + } + return 0; } -- 2.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/