提交 923837e1 编写于 作者: H Heinrich Schuchardt 提交者: Tom Rini

atcspi200: avoid possible NULL dereference

Check if ns before and not after dereferencing it.

Indicated by cppcheck.
Signed-off-by: NHeinrich Schuchardt <xypron.glpk@gmx.de>
上级 8639e34d
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册