[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240125145007.748295-4-tudor.ambarus@linaro.org>
Date: Thu, 25 Jan 2024 14:49:41 +0000
From: Tudor Ambarus <tudor.ambarus@...aro.org>
To: broonie@...nel.org,
andi.shyti@...nel.org,
arnd@...db.de
Cc: robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org,
conor+dt@...nel.org,
alim.akhtar@...sung.com,
linux-spi@...r.kernel.org,
linux-samsung-soc@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-arch@...r.kernel.org,
andre.draszik@...aro.org,
peter.griffin@...aro.org,
semen.protsenko@...aro.org,
kernel-team@...roid.com,
willmcvicker@...gle.com,
Tudor Ambarus <tudor.ambarus@...aro.org>
Subject: [PATCH v2 03/28] spi: s3c64xx: avoid possible negative array index
The platform id is used as an index into the fifo_lvl_mask array.
Platforms can come with a negative device ID, PLATFORM_DEVID_NONE (-1),
thus we risked a negative array index. Catch such cases and fail to
probe.
Fixes: 2b90807549e5 ("spi: s3c64xx: add device tree support")
Signed-off-by: Tudor Ambarus <tudor.ambarus@...aro.org>
---
drivers/spi/spi-s3c64xx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 2b5bb7604526..c3176a510643 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1189,6 +1189,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
"Failed to get alias id\n");
sdd->port_id = ret;
} else {
+ if (pdev->id < 0)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "Negative platform ID is not allowed\n");
sdd->port_id = pdev->id;
}
--
2.43.0.429.g432eaa2c6b-goog
Powered by blists - more mailing lists