projects
/
oweals
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8639e34
)
atcspi200: avoid possible NULL dereference
author
Heinrich Schuchardt
<xypron.glpk@gmx.de>
Wed, 31 Jan 2018 00:05:54 +0000
(
01:05
+0100)
committer
Tom Rini
<trini@konsulko.com>
Thu, 8 Feb 2018 03:06:18 +0000
(22:06 -0500)
Check if ns before and not after dereferencing it.
Indicated by cppcheck.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
drivers/spi/atcspi200_spi.c
patch
|
blob
|
history
diff --git
a/drivers/spi/atcspi200_spi.c
b/drivers/spi/atcspi200_spi.c
index 3e29df03a4da991c48c103a32afd7962d253324b..5b2e9d6264bd0f6e75447eae629d477193405494 100644
(file)
--- a/
drivers/spi/atcspi200_spi.c
+++ b/
drivers/spi/atcspi200_spi.c
@@
-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;
}