Skip to content

Commit 9caeb26

Browse files
MrVantrini
authored andcommitted
cmd: spi: check return value of strdup
Check return value of strdup. Signed-off-by: Peng Fan <[email protected]> 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]>
1 parent 3917c26 commit 9caeb26

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmd/spi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ static int do_spi_xfer(int bus, int cs)
5151

5252
snprintf(name, sizeof(name), "generic_%d:%d", bus, cs);
5353
str = strdup(name);
54+
if (!str)
55+
return -ENOMEM;
5456
ret = spi_get_bus_and_cs(bus, cs, 1000000, mode, "spi_generic_drv",
5557
str, &dev, &slave);
5658
if (ret)

0 commit comments

Comments
 (0)