mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
atcspi200: avoid possible NULL dereference
Check if ns before and not after dereferencing it. Indicated by cppcheck. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
8639e34d2c
commit
923837e159
1 changed files with 2 additions and 2 deletions
|
@ -297,6 +297,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
|
|||
return NULL;
|
||||
|
||||
ns = spi_alloc_slave(struct nds_spi_slave, bus, cs);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
switch (bus) {
|
||||
case SPI0_BUS:
|
||||
|
@ -316,8 +318,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
|
|||
ns->to = SPI_TIMEOUT;
|
||||
ns->max_transfer_length = MAX_TRANSFER_LEN;
|
||||
ns->slave.max_write_size = MAX_TRANSFER_LEN;
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
return &ns->slave;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue