Skip to contentSkip to conversation

cmd: spi: check return value of strdup

PATCH In review Peng Fan 2 participants 2 messages Mar 20, 2016 – Mar 27, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 cmd: spi: check return value of strdup

Check return value of strdup.

Cc Przemyslaw Marczak <[email protected]>
Cc Bin Meng <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Simon Glass <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Tom Rini <[email protected]>
---
 cmd/spi.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/spi.c +2 -0
index 64c3ffc..f16ef9a 100644
@@ -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)
Signature · 1 line
2.6.2
#1 lore raw
Quoted 9 lines · Peng Fan

Check return value of strdup.

Cc Przemyslaw Marczak <[email protected]>
Cc Bin Meng <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Simon Glass <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Tom Rini <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/b73bf0f5/attachment.sig>