* [U-Boot] [PATCH 1/1] atcspi200: avoid possible NULL dereference
@ 2018-01-31 0:05 Heinrich Schuchardt
2018-02-08 12:27 ` [U-Boot] [U-Boot, " Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2018-01-31 0:05 UTC (permalink / raw)
To: u-boot
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/atcspi200_spi.c b/drivers/spi/atcspi200_spi.c
index 3e29df03a4..5b2e9d6264 100644
--- 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;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [U-Boot, 1/1] atcspi200: avoid possible NULL dereference
2018-01-31 0:05 [U-Boot] [PATCH 1/1] atcspi200: avoid possible NULL dereference Heinrich Schuchardt
@ 2018-02-08 12:27 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-02-08 12:27 UTC (permalink / raw)
To: u-boot
On Wed, Jan 31, 2018 at 01:05:54AM +0100, Heinrich Schuchardt wrote:
> Check if ns before and not after dereferencing it.
>
> Indicated by cppcheck.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/286e7fe5/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-08 12:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 0:05 [U-Boot] [PATCH 1/1] atcspi200: avoid possible NULL dereference Heinrich Schuchardt
2018-02-08 12:27 ` [U-Boot] [U-Boot, " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.