From a9f870acdcef799db8e08207450a0ae7b2e85dd1 Mon Sep 17 00:00:00 2001 From: Youngmin Nam Date: Tue, 26 Jul 2016 19:32:53 +0900 Subject: [PATCH] [COMMON] spi: s3c64xx: prevent SPI port probe of exceeding max channel number This patch prevents SPI port probing when the SPI port number exceeds SPI max channel numbers. Change-Id: I5e4c1c60c2ea3db645118d946271a83e04548ebc Signed-off-by: Youngmin Nam --- drivers/spi/spi-s3c64xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 342f842ec111..dff3cf502023 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1494,6 +1494,12 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->port_id = pdev->id; } + if(sdd->port_id >= MAX_SPI_PORTS) { + dev_err(&pdev->dev, "the port %d exceeded MAX_SPI_PORTS(%d)\n" + , sdd->port_id, MAX_SPI_PORTS); + goto err0; + } + sdd->cur_bpw = 8; if (sci->dma_mode == DMA_MODE) { -- 2.20.1