[U-Boot] [PATCH] cmd: spi: check return value of strdup

Peng Fan van.freenix at gmail.com
Sun Mar 20 14:21:36 CET 2016


Check return value of strdup.

Signed-off-by: Peng Fan <van.freenix at gmail.com>
Cc: Przemyslaw Marczak <p.marczak at samsung.com>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Heiko Schocher <hs at denx.de>
Cc: Simon Glass <sjg at chromium.org>
Cc: Stefan Roese <sr at denx.de>
Cc: Tom Rini <trini at konsulko.com>
---
 cmd/spi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/spi.c b/cmd/spi.c
index 64c3ffc..f16ef9a 100644
--- a/cmd/spi.c
+++ b/cmd/spi.c
@@ -51,6 +51,8 @@ static int do_spi_xfer(int bus, int cs)
 
 	snprintf(name, sizeof(name), "generic_%d:%d", bus, cs);
 	str = strdup(name);
+	if (!str)
+		return -ENOMEM;
 	ret = spi_get_bus_and_cs(bus, cs, 1000000, mode, "spi_generic_drv",
 				 str, &dev, &slave);
 	if (ret)
-- 
2.6.2



More information about the U-Boot mailing list