[U-Boot] [PATCH 2/2] dm: spi: Check cs number before accessing slaves
Bin Meng
bmeng.cn at gmail.com
Thu Aug 29 14:09:38 UTC 2019
In spi_get_bus_and_cs() only bus number is checked before accessing
slaves. We should check cs number as well.
Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---
drivers/spi/spi-uclass.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 24de0b5..f633eb5 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -271,6 +271,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
{
struct udevice *bus, *dev;
struct dm_spi_slave_platdata *plat;
+ struct spi_cs_info info;
bool created = false;
int ret;
@@ -283,6 +284,11 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
printf("Invalid bus %d (err=%d)\n", busnum, ret);
return ret;
}
+ ret = spi_cs_info(bus, cs, &info);
+ if (ret) {
+ printf("Invalid cs %d (err=%d)\n", cs, ret);
+ return ret;
+ }
ret = spi_find_chip_select(bus, cs, &dev);
/*
--
2.7.4
More information about the U-Boot
mailing list