commit | bfae2744dd136198a97b480bc0cc1814663fe33b | [log] [tgz] |
---|---|---|
author | Sean Anderson <sean.anderson@seco.com> | Fri Apr 22 14:50:23 2022 -0400 |
committer | Tom Rini <trini@konsulko.com> | Thu May 05 15:06:02 2022 -0400 |
tree | 4db0bd4c46aecceff6c32be3017cefaa33372df2 | |
parent | 30705cd89271ea05ff6c65552af3dc4f0680a03c [diff] |
serial: smh: Check return value of strndup strndup can fail. Check for it. Fixes: 4855b39be ("serial: smh: Implement puts for DM") Signed-off-by: Sean Anderson <sean.anderson@seco.com>
diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c index 4328b3d..2561414 100644 --- a/drivers/serial/serial_semihosting.c +++ b/drivers/serial/serial_semihosting.c
@@ -54,6 +54,9 @@ } buf = strndup(s, len); + if (!buf) + return -ENOMEM; + smh_puts(buf); free(buf); return len;